This is my code to read my data from a CSV file row by row:
filepath = 'dataset-CalheirosMoroRita-2017.csv'
with open(filepath) as fp:
line = fp.readline()
cnt = 1
while line:
print("syntax {}: {}".format(cnt, line.strip()))
line = fp.readline()
cnt += 1
I am trying to taking rows of CSV file as an input(string)type for my function
def members(dictArg, new_list,length_of_string):
total=0
for list_item in new_list:
for letter, number in dictArg.items():
if list_item==letter:
print(letter)
total= total+number
print(total)
return ((total/length_of_string)*100)
I don't know how to get multiple rows one by one in new_list, new_list is the argument which take input from csv file but this is confusing me how to get input from csv by using for loop .