Responses to deleted message

… well isn’t that what you wrote?

Maybe, instead:

for row in csv
    add these key-value pairs to a list or something

reading the docs for the module will tell you what it offers

and, the purpose of the module, by the way, is to parse csv.
it’s all done for you. don’t treat it like a file, don’t split text. it gives you rows. job done.

If you mean that the key is included in all but the first, then, they’re not behaving differently, you reset the file handle’s location to the start of the file, what’s the first row? The keys.

What you ought to be doing is to iterate through the rows once, and collect all the information while you do so.

The reader is providing you with already-parsed, labeled rows. Make a list out of the rows and print them out if you’re unsure about what you’re given…


So if you agree that all information you’re looking for is already there, then, does it make sense that you also shouldn’t be doing weird things with the underlying thing? You already have what you are looking for. It might not be in the particular shape you’re looking for, but that doesn’t mean you should start over from zero. You may as well not use the csv module at all if you’re going to manage the file and parse it yourself. Start with the neatly packaged data and re-shape that.

A lot of this probably comes from not having read/browsed the module’s documentation, so that is the real answer here. That provides information about what the csv module at all can do for you, how you can use it, examples for common usage and so on.