I am trying to choose a random element from a csv file so I converted a csv_reader object to a list using the list() function but when I print it out, the list is empty. Why does this happen?
Code to replicate:
with open('data.csv','r') as file:
csvFile = csv.reader(file)
row_count = sum(1 for row in csvFile)
textToSend = list(csvFile)
print(textToSend)
#Outputs an empty list '[]'