Odd csv column-name truncation with only one column
Tim Chase
python.list at tim.thechases.com
Thu Jul 19 14:01:37 EDT 2012
More information about the Python-list mailing list
Thu Jul 19 14:01:37 EDT 2012
- Previous message (by thread): Odd csv column-name truncation with only one column
- Next message (by thread): Odd csv column-name truncation with only one column
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 07/19/12 08:52, Hans Mulder wrote: > Perhaps it should be documented that the Sniffer doesn't work > on single-column data. I think this would involve the least change in existing code, and go a long way towards removing my surprise. :-) > If you really need to read a one-column csv file, you'll have > to find some other way to produce a Dialect object. Perhaps the > predefined 'cvs.excel' dialect matches your data. If not, the > easiest way might be to manually define a csv.Dialect subclass. The problem I'm trying to solve is "here's a filename that might be comma/pipe/tab delimited, it has an 'email' column at minimum, and perhaps a couple others of interest if they were included" It's improbable that it's ONLY an email column, but my tests happened to snag this edge case. I can likely do my own sniffing by reading the first line, checking for tabs then pipes then commas (perhaps biasing the order based on the file-extension of .csv vs. .txt), and then building my own dialect information to pass to csv.DictReader It just seems unfortunate that the sniffer would ever consider [a-zA-Z0-9] as a valid delimiter. -tkc
- Previous message (by thread): Odd csv column-name truncation with only one column
- Next message (by thread): Odd csv column-name truncation with only one column
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list