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.
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?
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 ...
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 ...