I am very new to python and am really struggling with this problem. I have a csv file with different columns, labeled "height" "weight" "full_name" etc. I'm trying to create a function that will look through the full_name column and return the longest name. (So if the longest name in the folder was Rachel Smith, I'm trying to return that value.)
Here the code that's worked the best so far:
import csv
file = "personal_data.csv"
f = open(file)
reader = csv.reader(f, delimiter=",")
col_index = next(reader).index('full_name')
highest = max(rec[col_index] for rec in reader)
print(highest) #using this statement to test if it works
f.close()
I think it's not working because it's only printing Rachel, not her full name, Rachel Smith. I'm not really sure though.