python - How can I read individual lines from a CSV file? -
at moment i've got function:
def writer(file_name) open_file = open(file_name,"r+", newline='') csv_output = csv.writer(open_file) csv_output.writerow(student) open_file.close()
where student
is:
"string_1","string_2",int
i'm looking read through file first , check if "string_1"
i'm writing matches of "string_1"
s written, can't find built-in function lets me read each line , store list.
first, have open file reading, go through file line line , return, if "string_1" found:
def append_student(file_name, student) open(file_name, "r") f: line in csv.reader(f): if line[0] == student[0]: return open(file_name, "a") f: csv.writer(f).writerow(student)
Comments
Post a Comment