[Tutor] mapping header row to data rows in file
Peter Otten
__peter__ at web.de
Thu Jun 27 12:26:56 CEST 2013
eryksun wrote:
> On Thu, Jun 27, 2013 at 2:50 AM, Peter Otten <__peter__ at web.de> wrote:
>>
>> I'd prefer a csv.reader(), and if you have control over the table format
>> you should remove the extra whitespace in the source data.
>
> Say you AA.csv opened as f:
>
> >>> import csv
> >>> reader = csv.DictReader(f, skipinitialspace=1)
>
> >>> next(reader)
> {'Date': '22-Nov-2012', 'Series': 'EQ', 'Symbol': 'STER',
> {'Prev_Close': '9'}
> >>> next(reader)
> {'Date': '29-Nov-2012', 'Series': 'EQ', 'Symbol': 'STER',
> 'Prev_Close': '10'}
>
> and so on.
>From your previous posts I got the impression that I need to read the source
some more ;)
Now I'll have to extend that on the docs. And it is not even a new
feature...
Thanks for the update.
More information about the Tutor
mailing list