Where is the syntax for the dict() constructor ?!
Neil Cerutti
horpner at yahoo.com
Thu Jul 5 13:28:24 EDT 2007
On 2007-07-05, Captain Poutine <captainpoutine at gmail.com> wrote:
> I'm simply trying to read a CSV into a dictionary.
>
> (if it matters, it's ZIP codes and time zones, i.e.,
> 35983,CT
> 39161,CT
> 47240,EST
>
>
>
> Apparently the way to do this is:
>
> import csv
>
> dictZipZones = {}
>
> reader = csv.reader(open("some.csv", "rb"))
> for row in reader:
> # Add the row to the dictionary
In addition to Chris's answer, the csv module can read and write
dictionaries directly. Look up csv.DictReader and csv.DictWriter.
--
Neil Cerutti
In my prime I could have handled Michael Jordan. Of course, he would be only
12 years old. --Jerry Sloan
More information about the Python-list
mailing list