Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25618
| Date | 2012-07-19 06:21 -0500 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Odd csv column-name truncation with only one column |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2297.1342696862.4697.python-list@python.org> (permalink) |
tim@laptop:~/tmp$ python
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> from cStringIO import StringIO
>>> s = StringIO('Email\nfoo@example.com\nbar@example.org\n')
>>> s.seek(0)
>>> d = csv.Sniffer().sniff(s.read())
>>> s.seek(0)
>>> r = csv.DictReader(s, dialect=d)
>>> r.fieldnames
['Emai', '']
I get the same results using Python 3.1.3 (also readily available on
Debian Stable), as well as working directly on a file rather than a
StringIO.
Any reason I'm getting ['Emai', ''] (note the missing ell) instead
of ['Email'] as my resulting fieldnames? Did I miss something in
the docs?
-tkc
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Odd csv column-name truncation with only one column Tim Chase <python.list@tim.thechases.com> - 2012-07-19 06:21 -0500
Re: Odd csv column-name truncation with only one column Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 12:08 +0000
Re: Odd csv column-name truncation with only one column Hans Mulder <hansmu@xs4all.nl> - 2012-07-19 15:52 +0200
Re: Odd csv column-name truncation with only one column Tim Chase <python.list@tim.thechases.com> - 2012-07-19 13:01 -0500
Re: Odd csv column-name truncation with only one column Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-19 17:10 -0400
Re: Odd csv column-name truncation with only one column Hans Mulder <hansmu@xs4all.nl> - 2012-07-20 18:59 +0200
Re: Odd csv column-name truncation with only one column Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-20 14:09 -0400
Re: Odd csv column-name truncation with only one column Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-20 08:31 +0000
csiph-web