Issue1381476
Created on 2005-12-15 11:04 by wwwingman, last changed 2009-02-11 22:54 by ajaksu2. This issue is now closed.
| Messages (8) | |||
|---|---|---|---|
| msg27074 - (view) | Author: Christian Harms (wwwingman) | Date: 2005-12-15 11:04 | |
Hi,
the csv.reader produce a endless loop, ifan parsing
Error is in the last line of the CSV-File. If you put
an "\r" in the last line, cvs.Error is raised and
StopIteration will lost.
import csv, StringIO
fp = StringIO.StringIO("line1\nline2\rerror")
reader = csv.reader(fp)
while 1:
try:
print reader.next()
except csv.Error:
print "Error"
except StopIteration:
break
Die Problem is in python 2.3 AND python 2.4. Other
version are not checked.
|
|||
| msg27075 - (view) | Author: Thomas Lee (krumms) ![]() |
Date: 2005-12-17 15:17 | |
Logged In: YES user_id=315535 I think this may be fixed in subversion: tom@vanilla:~/work/python$ svn info Path: . URL: http://svn.python.org/projects/python/trunk Repository UUID: 6015fed2-1504-0410-9fe1-9d1591cc4771 Revision: 41731 Node Kind: directory Schedule: normal Last Changed Author: fredrik.lundh Last Changed Rev: 41729 Last Changed Date: 2005-12-17 18:33:21 +1000 (Sat, 17 Dec 2005) Properties Last Updated: 2005-12-17 21:44:46 +1000 (Sat, 17 Dec 2005) tom@vanilla:~/work/python$ python -V Python 2.4.2 tom@vanilla:~/work/python$ python Sandbox/csv_reader_test.py ['line1'] ERROR: newline inside string tom@vanilla:~/work/python$ ./python -V Python 2.5a0 tom@vanilla:~/work/python$ ./python Sandbox/csv_reader_test.py ['line1'] ERROR: new-line character seen in unquoted field - do you need to open the file in universal-newline mode? |
|||
| msg27076 - (view) | Author: Thomas Lee (krumms) ![]() |
Date: 2005-12-17 16:56 | |
Logged In: YES user_id=315535 Actually, the problem may not be a problem with the csv module at all, it may be a misinterpretation of the API on the submitters part. Is there any time a non-fatal csv.Error would/could be raised? Seems to me that a csv.Error would imply a StopIteration/break ... |
|||
| msg27077 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2005-12-17 17:02 | |
Logged In: YES user_id=1188172 Let the expert judge. |
|||
| msg27078 - (view) | Author: Christian Harms (wwwingman) | Date: 2006-01-03 08:56 | |
Logged In: YES
user_id=1405594
>birkenfeld: csv.Error would imply a StopIteration/break ...
No, this Error says only: "Can not parse THIS line ...".
This exception is used for reading buggy
outlook-Export-CSV-Files und trying to read some lines (not
all). And if the error is in the last line, the
StopIteration will be forgotten and the Error will be
produced in a endless-loop.
input = StringIO.StringIO("1.\rerror\n2.ok\n3.\rerr")
#insert my while-loop
#Output:
>Error
>2.ok
>Error
>Error
...
|
|||
| msg27079 - (view) | Author: Calvin Spealman (ironfroggy) | Date: 2007-01-13 06:48 | |
How do you expect it to handle this? Should it treat \r bytes as a newline or as content of the field? |
|||
| msg81569 - (view) | Author: Daniel Diniz (ajaksu2) | Date: 2009-02-10 18:10 | |
Invalid per discussion. |
|||
| msg81684 - (view) | Author: Daniel Diniz (ajaksu2) | Date: 2009-02-11 22:54 | |
Confirmed as working on trunk and py3k. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2009-02-11 22:54:02 | ajaksu2 | set | status: open -> closed resolution: out of date messages: + msg81684 |
| 2009-02-10 18:10:40 | ajaksu2 | set | nosy:
+ ajaksu2 messages: + msg81569 title: csv.reader endless loop -> csv.reader endless loop |
| 2005-12-15 11:04:26 | wwwingman | create | |
