Commit 42bbdb80 authored by Michal Čihař's avatar Michal Čihař

Fix CSV parsing with Python 3

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 1e6d2aac
...@@ -1250,14 +1250,15 @@ class CSVFormat(FileFormat): ...@@ -1250,14 +1250,15 @@ class CSVFormat(FileFormat):
# Try reading header # Try reading header
reader = csv.reader(fileobj, store.dialect) reader = csv.reader(fileobj, store.dialect)
header = next(reader) header = next(reader)
fileobj.close()
# We seem to have match # We seem to have match
if len(header) != 2: if len(header) != 2:
fileobj.close()
return store return store
fileobj.seek(0) result = storeclass(fieldnames=['source', 'target'])
return storeclass(fileobj, ['source', 'target']) result.parse(content.encode('utf-8'))
return result
@register_fileformat @register_fileformat
......
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