fix unicode encoding of unicode strings, add delimeter option in CSVSource
This commit is contained in:
parent
2e1480d778
commit
20a7beebab
@ -360,6 +360,8 @@ class UnicodeFilter(Filter):
|
|||||||
for key, value in record.iteritems():
|
for key, value in record.iteritems():
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
record[key] = unicode(value, self._encoding, self._errors)
|
record[key] = unicode(value, self._encoding, self._errors)
|
||||||
|
elif isinstance(value, unicode):
|
||||||
|
record[key] = value.encode(self._encoding, self._errors)
|
||||||
return record
|
return record
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
|
@ -22,9 +22,9 @@ class CSVSource(object):
|
|||||||
ignoring the first row (presumed to be column names).
|
ignoring the first row (presumed to be column names).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, csvfile, fieldnames=None, skiprows=0):
|
def __init__(self, csvfile, fieldnames=None, skiprows=0, delimiter=','):
|
||||||
import csv
|
import csv
|
||||||
self._dictreader = csv.DictReader(csvfile, fieldnames)
|
self._dictreader = csv.DictReader(csvfile, fieldnames, delimiter=delimiter)
|
||||||
for _ in xrange(skiprows):
|
for _ in xrange(skiprows):
|
||||||
self._dictreader.next()
|
self._dictreader.next()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user