Reading a CSV file into a list of dictionaries
John Machin
sjmachin at lexicon.net
Tue Jun 7 16:29:59 EDT 2005
Laurent RAHUEL wrote:
> RFQ wrote:
>
>
>>Hi, I'm struggling here to do the following with any success:
>>
>>I have a comma delimited file where each line in the file is something
>>like:
>>
>>PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,...
>
>
> This is NOT a CSV file. A CSV file would be :
>
> PNumber,Contractor,Architect,...
> 2056,XYZ Contracting,ABC Architects,...
>
CSV is an acronym for "Comma-Separated Values". It does not imply
anything about the contents of the fields. The OP's file *is* a CSV
file. Yes, the contents do represent an unusual application of the CSV
format -- however a bus full of parcels instead of people is still a bus.
> Then, you could use the built-in CSV module of recent python versions.
Python is a case-sensitive language. The name of the module is "csv".
The OP could use the csv module with his data.
More information about the Python-list
mailing list