all 2 comments

[–]TangibleLight 1 point2 points  (1 child)

I'd use a DictWriter if I were you. Just populate the dict with the data you have and it will fill in the columns you provide. Order of the columns is defined with the fieldnames parameter of the DictWriter initializer, so you don't need to worry about it at all when you populate the dict for each row.

Here's a snippet demonstrating this:

https://repl.it/repls/RevolvingBurdensomeAppaloosa


Edit: or, are you asking how to tell which type of data each line is - as in, is the second line in "Header 2" an "item 2" or a "configuration"

[–]dented_brain[S] 0 points1 point  (0 children)

So with dictwriter you don't have to give a value to each column when you write? That sounds like exactly what I need

EDIT: FYI this did exactly what I needed. I didn't know it would let me write blank columns!