chopping csv-files (newbie)
Bjørn Ove Grøtan
bgrotanLOVELYSPAM at itea.ntnu.no
Thu Apr 18 03:32:28 EDT 2002
I have a csv-file.. delimited by ;
example-line from the csv-file
"90383";"ooooxWOW 90383;";"Some discription";
"99875";"ooooxSomede90383;0000xNewli99875;";"New line-descriptor";
In this file there is 3 fields extracted from a database.
The second field, can vary som 1 to 4 fields separated by ; but not with
"
What I need to do is to build an array after opening a given file
with the information from the second and third fields.
E.g:
90383 Some discription
99875 New line-descriptor, Some discription
You see where I'm going at?
the second record in this file has a reference to the first record in
its second field.
I have no choice to rebuild the database for my needs since I only have
read-access to it and have nothing to do with the database itself.
I also want to save the records in the array (hash-table?) to a file
Could someone please help me with an example on how to do this?
Saving the hash-table to a file I can manage.. but the above part is a
bit tricky for me since I don't know enough python..
Best regards
Bjørn Ove Grøtan
More information about the Python-list
mailing list