Commit 7530716e authored by Michal Čihař's avatar Michal Čihař

Better support for Python 3 in CSV loader

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 4e3a6245
...@@ -1241,12 +1241,15 @@ class CSVFormat(FileFormat): ...@@ -1241,12 +1241,15 @@ class CSVFormat(FileFormat):
if store.fieldnames != ['location', 'source', 'target']: if store.fieldnames != ['location', 'source', 'target']:
return store return store
fileobj = StringIOMode(storefile.name, content) if not isinstance(content, six.string_types):
content = content.decode('utf-8')
fileobj = csv.StringIO(content)
storefile.close() storefile.close()
# Try reading header # Try reading header
reader = csv.reader(fileobj, store.dialect) reader = csv.reader(fileobj, store.dialect)
header = reader.next() header = next(reader)
# We seem to have match # We seem to have match
if len(header) != 2: if len(header) != 2:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment