reader creates an iterator which essentially iterates over the csv file line-by-line.
iterators in Python iterate over something and once an iteration is completed they are exhausted (because they reach the end of what they were iterating over). They then hold nothing in them. (Note: this is a simplified explanation applicable to this scenario)
So, when you use the above code, list(read)[0], the iterator goes through the csv once, all of that gets saved into a list, and then the iterator, read, is empty.
Then, when you use the code -
lister = list(read)
lister will be empty because read is now empty. You can print out lister in your code and it will return a [].
Just remove that line of code for your header and your code works as expected.
Also, please try to make sure your question/post titles are descriptive of the problem you are facing. It’s easier for other students to find them if need be.
thank you for your help! i was really having trouble.
Sorry about the title. I didn’t really understand what the problem was so it was hard for me to think of a descriptive title so I thought just putting the problem number would be enough. I’ll be more creative next time.
Hi. You will have to create a new post for your question and also share the error you get. I would also recommend formatting your code properly in that new post. Someone can then answer it accordingly.