Bugs item #1381476, was opened at 2005-12-15 11:04 Message generated for change (Comment added) made by wwwingman You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1381476&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Christian Harms (wwwingman) Assigned to: Andrew McNamara (andrewmcnamara) Summary: csv.reader endless loop Initial Comment: 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. ---------------------------------------------------------------------- >Comment By: Christian Harms (wwwingman) Date: 2006-01-03 08:56 Message: 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 ... ---------------------------------------------------------------------- Comment By: Reinhold Birkenfeld (birkenfeld) Date: 2005-12-17 17:02 Message: Logged In: YES user_id=1188172 Let the expert judge. ---------------------------------------------------------------------- Comment By: Thomas Lee (krumms) Date: 2005-12-17 16:56 Message: 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 ... ---------------------------------------------------------------------- Comment By: Thomas Lee (krumms) Date: 2005-12-17 15:17 Message: Logged In: YES user_id=315535 I think this may be fixed in subversion: [EMAIL PROTECTED]:~/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) [EMAIL PROTECTED]:~/work/python$ python -V Python 2.4.2 [EMAIL PROTECTED]:~/work/python$ python Sandbox/csv_reader_test.py ['line1'] ERROR: newline inside string [EMAIL PROTECTED]:~/work/python$ ./python -V Python 2.5a0 [EMAIL PROTECTED]:~/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? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1381476&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com