Commit Graph

19 Commits

Author SHA1 Message Date
Guido van Rossum b940e113bf SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V"
(b) V is now limited to a simple name (local variable)
(c) V is now deleted at the end of the except block
2007-01-10 16:19:56 +00:00
Guido van Rossum 89da5d7c3d Kill reduce(). A coproduction of John Reese, Jacques Frechet, and Alex M. 2006-08-22 00:21:25 +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