This command will take the file "file.txt" and use the comma (",") as the field separator. It will then generate a random number between 0 and 100, and add the second field of each line until the sum is greater than the random number. When this happens, it will print the first field of that line and exit.
awk -F, 'BEGIN{srand();v=rand()*100}{sum+=$2;if(sum>v){print $1;exit}}' file.txt