[FIX] handling of single-line files sent for preview

bzr revid: xmo@openerp.com-20131015100313-sdgqx1t43922kgq8
This commit is contained in:
Xavier Morel 2013-10-15 12:03:13 +02:00
parent f2feffe5e2
commit e0493cd6d4
1 changed files with 3 additions and 2 deletions

View File

@ -224,12 +224,13 @@ class ir_import(orm.TransientModel):
headers, matches = self._match_headers(rows, fields, options)
# Match should have consumed the first row (iif headers), get
# the ``count`` next rows for preview
preview = itertools.islice(rows, count)
preview = list(itertools.islice(rows, count))
assert preview, "CSV file seems to have no content"
return {
'fields': fields,
'matches': matches or False,
'headers': headers or False,
'preview': list(preview),
'preview': preview,
}
except Exception, e:
# Due to lazy generators, UnicodeDecodeError (for