[issue15407] CSV parser fails to iterate properly on 2.6.6
Cal Leeming
report at bugs.python.org
Fri Jul 20 17:43:02 CEST 2012
New submission from Cal Leeming <cal.leeming at simplicitymedialtd.co.uk>:
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 at 3stooges.com","actor"
"Jerome","Lester","Howard","Curly","curly at 3stooges.com","actor"
"Larry","","Fine","Larry","larry at 3stooges.com","musician"
"Jerome","","Besser","Joe","joe at 3stooges.com","actor"
"Joe","","DeRita","CurlyJoe","curlyjoe at 3stooges.com","actor"
"Shemp","","Howard","Shemp","shemp at 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 at 3stooges.com']
['', '']
['actor']
[]
['Jerome']
['', '']
['Lester']
['', '']
['Howard']
['', '']
['Curly']
['', '']
['curly at 3stooges.com']
['', '']
['actor']
[]
['Larry']
['', '']
['']
['', '']
['Fine']
['', '']
['Larry']
['', '']
['larry at 3stooges.com']
['', '']
['musician']
[]
['Jerome']
['', '']
['']
['', '']
['Besser']
['', '']
['Joe']
['', '']
['joe at 3stooges.com']
['', '']
['actor']
[]
['Joe']
['', '']
['']
['', '']
['DeRita']
['', '']
['CurlyJoe']
['', '']
['curlyjoe at 3stooges.com']
['', '']
['actor']
[]
['Shemp']
['', '']
['']
['', '']
['Howard']
['', '']
['Shemp']
['', '']
['shemp at 3stooges.com']
['', '']
['actor']
[]
----------
components: None
messages: 165938
nosy: sleepycal
priority: normal
severity: normal
status: open
title: CSV parser fails to iterate properly on 2.6.6
versions: Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15407>
_______________________________________
More information about the Python-bugs-list
mailing list