Less strict CSV processing, to allow dirty input.
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import csv
|
import csv
|
||||||
|
import warnings
|
||||||
|
|
||||||
from bonobo.config import Option
|
from bonobo.config import Option
|
||||||
from bonobo.config.options import RemovedOption
|
from bonobo.config.options import RemovedOption
|
||||||
@ -62,7 +63,7 @@ class CsvReader(FileReader, CsvHandler):
|
|||||||
|
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if len(row) != field_count:
|
if len(row) != field_count:
|
||||||
raise ValueError('Got a line with %d fields, expecting %d.' % (
|
warnings.warn('Got a line with %d fields, expecting %d.' % (
|
||||||
len(row),
|
len(row),
|
||||||
field_count,
|
field_count,
|
||||||
))
|
))
|
||||||
@ -81,6 +82,6 @@ class CsvWriter(FileWriter, CsvHandler):
|
|||||||
if not lineno:
|
if not lineno:
|
||||||
headers.set(headers.value or row.keys())
|
headers.set(headers.value or row.keys())
|
||||||
writer.writerow(headers.get())
|
writer.writerow(headers.get())
|
||||||
writer.writerow(row[header] for header in headers.get())
|
writer.writerow(row.get(header, '') for header in headers.get())
|
||||||
lineno += 1
|
lineno += 1
|
||||||
return NOT_MODIFIED
|
return NOT_MODIFIED
|
||||||
|
|||||||
Reference in New Issue
Block a user