def getnamesofstaff(file): names_of_staff = [] print("file =",file) for lines in file: line = lines.strip().split(",") name = line[0] if name in names_of_staff: breakpoint else: names_of_staff.append(name) names_of_staff.sort(reverse=False) return names_of_staffdef readfile(file): f = open(file, "r") return fdef output() infile = enter_file.get() input_file = "csvFiles\\" + infile +".csv" ForFeesCovered.filecleaner(input_file) f = ForFeesCovered.readfile(input_file) list_from_file = csvEditor.editnewcsv(input_file) csvEditor.makefinalcsv(list_from_file) f.close() new_file = "Final Results\\Result.csv" file = ForFeesCovered.readfile(new_file) staff = ForFeesCovered.get_name_of_staff(file) file.close()ForFeesCovered.get_name_of_staff(): ForFeesCovered is another file that I have to code written in. Get_name_of_staff() is a function that takes in a CSV file and parses through it, pulling out all the staff names, throwing them into a list. For example, if the CSV file read "Adams, $0.5" Get_name_of_staff() would read the line and then pull out "Adams" and put it into a list.
These are the 3 functions that I am using. I am trying to open a CSV file and pull out the names in one of the columns. But whenever I run it. It throws this error "TypeError: '_io.TextIOWrapper' object is not subscriptable". I think this happens after reading the whole file. It tries to read the line after the end of the file which causes the program to throw the error.