Changeset 391 for python/trunk/Lib/csv.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/csv.py
r2 r391 133 133 self.writer = writer(f, dialect, *args, **kwds) 134 134 135 def writeheader(self): 136 header = dict(zip(self.fieldnames, self.fieldnames)) 137 self.writerow(header) 138 135 139 def _dict_to_list(self, rowdict): 136 140 if self.extrasaction == "raise": … … 171 175 """ 172 176 173 quotechar, d elimiter, skipinitialspace = \177 quotechar, doublequote, delimiter, skipinitialspace = \ 174 178 self._guess_quote_and_delimiter(sample, delimiters) 175 179 if not delimiter: … … 185 189 quoting = QUOTE_MINIMAL 186 190 # escapechar = '' 187 doublequote = False 188 191 192 dialect.doublequote = doublequote 189 193 dialect.delimiter = delimiter 190 194 # _csv.reader won't accept a quotechar of '' … … 218 222 219 223 if not matches: 220 return ('', None, 0) # (quotechar, delimiter, skipinitialspace)221 224 # (quotechar, doublequote, delimiter, skipinitialspace) 225 return ('', False, None, 0) 222 226 quotes = {} 223 227 delims = {} … … 256 260 skipinitialspace = 0 257 261 258 return (quotechar, delim, skipinitialspace) 262 # if we see an extra quote between delimiters, we've got a 263 # double quoted format 264 dq_regexp = re.compile( 265 r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \ 266 {'delim':re.escape(delim), 'quote':quotechar}, re.MULTILINE) 267 268 269 270 if dq_regexp.search(data): 271 doublequote = True 272 else: 273 doublequote = False 274 275 return (quotechar, doublequote, delim, skipinitialspace) 259 276 260 277 … … 266 283 number. 267 284 1) build a table of the frequency of each character on every line. 268 2) build a table of freq encies of this frequency (meta-frequency?),285 2) build a table of frequencies of this frequency (meta-frequency?), 269 286 e.g. 'x occurred 5 times in 10 rows, 6 times in 1000 rows, 270 287 7 times in 2 rows'
Note:
See TracChangeset
for help on using the changeset viewer.