Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to store specific parts of a file into a set, but I am unable to convert

ID: 3545234 • Letter: I

Question

I need to store specific parts of a file into a set, but I am unable to convert the strings within the file into a float. What I'm doing here is accessing the third column of the csv file (n[2]) and then comparing it with a string "Arable land." I have no problem with this part, but the float(n[4]), which is supposed to access the numbers on column 5, keeps returning an error (cannot convert string to float). Is anyone able to help me with this?


CArable = set();

reader6 = csv.reader(open('WorldBank2012DataWORegions.csv','rU'), delimiter = ',');

for n in reader6:

if n[2] == "Arable land (% of land area)":

                  if float(n[4]) < 10.0:

         CArable.add(n[1]);

print CArable;

Explanation / Answer

if float(tmp)