Bugs item #1431091, was opened at 2006-02-13 19:47 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1431091&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: Extension Modules Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Vinko (vvrsalob) Assigned to: Nobody/Anonymous (nobody) Summary: CSV Sniffer fails to report mismatch of column counts Initial Comment: If one line of a CSV file is missing one or more commas, the delimiter detection code of the Sniffer class fails, setting delimiter to an empty string. This leads to a totally misleading error when using has_header(). This code shows the problem (Python 2.4.2, FC3 and Ubuntu Breezy): import csv str1 = "a,b,c,d\r\n1,2,foo bar,dead beef\r\nthis,line,is,ok\r\n" str2 = "a,b,c,d\r\n1,2,foo bar,dead beef\r\nthis,line is,not\r\n" s = csv.Sniffer() d1 = s.sniff(str1) d2 = s.sniff(str2) for line in str1.split('\r\n'): print line.count(',') print d1.delimiter print s.has_header(str1) for line in str2.split('\r\n'): print line.count(',') print d2.delimiter print s.has_header(str2) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1431091&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com