Commit Graph

23 Commits

Author SHA1 Message Date
Skip Montanaro b4fd4d37a1 Patch from Thomas Barr so that csv.Sniffer will set doublequote property.
Closes issue 6606.
2009-09-28 02:12:27 +00:00
Brett Cannon 88f801d409 Update __all__ for cookielib, csv, os, and urllib2 for objects imported into
the module but exposed as part of the API.
2008-08-18 00:46:22 +00:00
Brett Cannon 9fc5631be6 Silence warnings in csv about using reduce() when run under -3 by using
functools.reduce() instead.
2008-08-09 23:39:11 +00:00
Skip Montanaro a032bf41f6 accept issue 3436 2008-08-08 22:52:51 +00:00
Georg Brandl 77354cf5ef Issue #2432: give DictReader the dialect and line_num attributes
advertised in the docs.
2008-03-21 20:01:51 +00:00
Georg Brandl 94fe3f58d0 Patch #1635454: the csv.DictWriter class now includes the offending
field names in its exception message if you try to write a record with
a dictionary containing fields not in the CSV field names list.
2007-03-13 09:32:11 +00:00
Skip Montanaro 39b29be8a6 Fix a delimiter detection problem in sniffer. Sniffing "a|b|c\r\n" was
returning 'a' as the delimiter.  It now returns '|', but not because I
understood better what the code was supposed to do.  Would someone that
understands the idea behind _guess_delimiter() (see its doc string) look to
see if my fallback choice is better than before or if it's just serendipity
that I picked the proper delimiter?
2005-12-30 05:09:48 +00:00
Skip Montanaro 91bb70c5c0 Fix for problem with Sniffer class. If your delimiter is whitespace and the
last field was empty it would strip the delimiter and incorrectly guess that
"" was the delimiter.  Reported in c.l.py by Laurent Laporte.  Will
backport.
2005-12-28 15:37:25 +00:00
Andrew McNamara 31d8896ee2 Rename csv.set_field_limit to csv.field_size_limit (since it both sets and
gets).
2005-01-12 03:45:10 +00:00
Andrew McNamara e4d05c4f93 Set an upper limit on the size of the field buffer, raise an exception
when this limit is reached. Limit defaults to 128k, and is changed
by module set_field_limit() method. Previously, an unmatched quote
character could result in the entire file being read into the field
buffer, potentially exhausting virtual memory.
2005-01-11 07:32:02 +00:00
Andrew McNamara 7130ff5eb9 Replace python-coded validation of csv dialect with a call to the C
dialect type (which has a better idea of what is and isn't valid).
2005-01-11 02:22:47 +00:00
Andrew McNamara 1196cf185c Improved the implementation of the internal "dialect" type. The new
implementation features better error reporting, and better compliance
with the PEP.
2005-01-07 04:42:45 +00:00
Skip Montanaro f26285ce0b add a couple missing docstrings 2005-01-05 06:54:58 +00:00
Skip Montanaro dffeed3ffa Make the fieldnames argument optional in the DictReader. If self.fieldnames
is None, the next row read is used as the fieldnames.  In the common case,
this means the programmer doesn't need to know the fieldnames ahead of time.
The first row of the file will be used.  In the uncommon case, this means
the programmer can set the reader's fieldnames attribute to None at any time
and have the next row read as the next set of fieldnames, so a csv file can
contain several "sections", each with different fieldnames.
2003-10-03 14:03:01 +00:00
Skip Montanaro 3f7a94824e **kwds arg was missing from __init__ for Dict{Reader,Writer} classes.
will backport.
2003-09-06 19:52:12 +00:00
Fred Drake 6f7b213dda use the long names for re compilation options; this makes it easier to
figure out what the code is doing
2003-09-02 16:01:07 +00:00
Raymond Hettinger f31cb0cbcf One more multiple exception catch should be in a tuple. 2003-06-12 04:05:00 +00:00
Raymond Hettinger abe14e6f04 The multiple exception catch should be in a tuple. 2003-06-12 03:59:17 +00:00
Raymond Hettinger 39a5592001 SF Patch #744104: Remove eval() from csv
Eliminates the eval() step in the csv module resulting in better
security, more clarity, and a little speed.

The idea is to make successive attempts to coerce the string to
a python type:
    int(s), long(s), float(s), etc.

As a by-product, eliminates a bare 'except' statement.
2003-06-12 03:01:55 +00:00
Skip Montanaro 7789237331 * Correct Sniffer doc to correspond to the implementation.
* Add optional delimiters arg to Sniffer.sniff() which restricts the set of
  candidate field delimiters.
2003-05-19 15:33:36 +00:00
Skip Montanaro 1448d4719c rework Sniffer api significantly 2003-04-25 14:47:16 +00:00
Fred Drake 7c852f33a2 Attempt to deal with some obvious errors in the code. These were all
due to using a single module-level namespace where multiple namespaces
were used before.

There *really* need to be tests for the sniffer stuff.  This could
have been avoided.

Skip, please review, and add sniffer tests!
2003-04-25 14:27:00 +00:00
Skip Montanaro 04ae7056cf cvs is going to be a module again 2003-04-24 20:21:31 +00:00