This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sleepycal
Recipients sleepycal
Date 2012-07-20.15:43:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342798982.0.0.719317357124.issue15407@psf.upfronthosting.co.za>
In-reply-to
Content
Getting some extremely strange behavior when attempting to parse a fairly standard CSV in Python 2.6.6.

I've tried a whole different mixture of dialects, quoting options, line terminators etc, and none seem to get a happy ending.

Spent about 2 hours banging my head against a brick wall on this, and struggling to see how the CSV libs could be so fundamentally broken, given that I couldn't find any other related bugs.

I have attempted to parse the following CSV data:

"First","Middle","Last","Nickname","Email","Category"
"Moe","","Howard","Moe","moe@3stooges.com","actor"
"Jerome","Lester","Howard","Curly","curly@3stooges.com","actor"
"Larry","","Fine","Larry","larry@3stooges.com","musician"
"Jerome","","Besser","Joe","joe@3stooges.com","actor"
"Joe","","DeRita","CurlyJoe","curlyjoe@3stooges.com","actor"
"Shemp","","Howard","Shemp","shemp@3stooges.com","actor"

The code used to parse was this:

datx = open("data.txt", "rb").read()
rows = csv.reader( datx , dialect="wat")
for row in rows:
    print x

The output given is this:

['First']
['', '']
['Middle']
['', '']
['Last']
['', '']
['Nickname']
['', '']
['Email']
['', '']
['Category']
[]
['Moe']
['', '']
['']
['', '']
['Howard']
['', '']
['Moe']
['', '']
['moe@3stooges.com']
['', '']
['actor']
[]
['Jerome']
['', '']
['Lester']
['', '']
['Howard']
['', '']
['Curly']
['', '']
['curly@3stooges.com']
['', '']
['actor']
[]
['Larry']
['', '']
['']
['', '']
['Fine']
['', '']
['Larry']
['', '']
['larry@3stooges.com']
['', '']
['musician']
[]
['Jerome']
['', '']
['']
['', '']
['Besser']
['', '']
['Joe']
['', '']
['joe@3stooges.com']
['', '']
['actor']
[]
['Joe']
['', '']
['']
['', '']
['DeRita']
['', '']
['CurlyJoe']
['', '']
['curlyjoe@3stooges.com']
['', '']
['actor']
[]
['Shemp']
['', '']
['']
['', '']
['Howard']
['', '']
['Shemp']
['', '']
['shemp@3stooges.com']
['', '']
['actor']
[]
History
Date User Action Args
2012-07-20 15:43:02sleepycalsetrecipients: + sleepycal
2012-07-20 15:43:01sleepycalsetmessageid: <1342798982.0.0.719317357124.issue15407@psf.upfronthosting.co.za>
2012-07-20 15:43:01sleepycallinkissue15407 messages
2012-07-20 15:43:00sleepycalcreate