Open mheijink opened 5 years ago
Can you share file contents or an equivalent code so I can reproduce here?
OrgDefinedID;Final Adjusted Grade test1;46.28 test2;80.28 test3;61,2 % TrainingStudent01; test4; 10 test5; 11 test6; 12
@mheijink I'm trying to reproduce here using io.BytesIO
(is it equivalent to your request.FILES['file']
object?) but couldn't. Could you please help creating a reproducible code? I've tried:
import io
import rows
filename = "test.csv"
table = rows.import_from_csv(filename)
with open(filename, mode="rb") as fobj:
data = fobj.read()
table2 = rows.import_from_csv(io.BytesIO(data))
assert list(table) == list(table2) # no AssertionError raised, so tables have the same content
request.FILES['file'] is a of type django.core.files.uploadedfile.InMemoryUploadedFile If I change it like this it works
`` import rows from io import BytesIO
fp = request.FILES['bestand']
for chunk in fp.chunks():
logger.debug(type(chunk))
logger.debug(chunk)
rows_data = rows.import_from_csv(BytesIO(chunk))
for d in rows_data:
logger.debug(d)
logger.debug(d[0])
logger.debug(d[1])
``
I have a simple csv with ; as delimiter. rows.import_from_csv("test.csv") works great if I read it from a disk file.
But when reading the same file when it is uploaded is not working. rows.import_from_csv(request.FILES['file'])
discover_dialect falls back to 'excel'