I am a teacher who is trying to create a program that will display students that are comfortable reading in class. They have filled out a form that populates a spreadsheet if they choose that they are comfortable.
I would like to randomly sort their names from the .csv, so that I get a single name each time I run the program. I keep getting an error that my file has no len().
Here is the code I have so far:
import csv
import random
with open('1st_period.csv', 'r') as student_csv_file:
csv_reader = csv.reader(student_csv_file)
next(csv_reader)
#This skips over the first line in the .csv (first_name, last_name)
for line in csv_reader:
random.shuffle(csv_reader)
print(line[0])
Here is my .csv file in same folder as the python file
first_name
Joshua
Jeremy
Mary
Martha
How can I do this correctly?
Aucun commentaire:
Enregistrer un commentaire