csv dictreader

brnstrmrs brnstrmrs at gmail.com
Wed Mar 19 14:06:40 EDT 2008


I am trying to use the dictionary reader to import the data from a csv
file and create a dictnary from it but just can't seem to figure it
out.

Here is my code:
>>>import csv
>>>reader = csv.DictReader(open('table.csv'))
>>>for row in reader:
>>>print row

my csv files looks like this:

Bytecode,Element
\x00\x00,0000
\x01\x00,0001
....
\x09\x00,0009

My output shows:
{'Bytecode': '\\x00\\x00', 'Element': '0000'}
{'Bytecode': '\\x01\\x00', 'Element': '0001'}
...
{'Bytecode': '\\x09\\x00', 'Element': '0009'}

1. how can I get access to this directory
2. why does the values come with two backslashs infront of the "x"



More information about the Python-list mailing list