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):
# Try reading header
reader = csv.reader(fileobj, store.dialect)
header = next(reader)
fileobj.close()
# We seem to have match
if len(header) != 2:
fileobj.close()
return store
fileobj.seek(0)
return storeclass(fileobj, ['source', 'target'])
result = storeclass(fieldnames=['source', 'target'])
result.parse(content.encode('utf-8'))
return result
@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