I am dealing with a CSV file similar to this one
foo; val1; position1
bar; name1; address1; phone_nbr1
bar; name2; address2; phone_nbr2
foo; val2; position2
bar; name3; address3; phone_nbr3
bar; name4; address4; phone_nbr4
bar; name5; address5; phone_nbr5
bar; name6; address6; phone_nbr6
foo; val3; position3
Needless to say, I cannot modify the CSV.
Instances displayed in foo lines are different from the ones with bar lines (notice they don't even have the same number of fields)
I need simply reading this data, no need to write it.
My first idea was to separate the file into two temporary files and then read each one separately with a csv.DictReader, however I really don't like this approach.
Is there a simpler way to do this? I would like to avoid if possible having to write files to disk.
For the record, I'm using Python2.7 on a Solaris 10 machine.