i would like to store the data from my uploaded CSV file, called
data_file
I cant loop over the rows by column name in my csv file. I get Encoding errors(UTF, ASCII), also when i use IO String. I am new to django so i dont know what i do wrong.
I tried to do this in my view with:
def upload(request):
form = UploadForm(request.POST, request.FILES)
if form.is_valid():
f = io.TextIOWrapper(form.cleaned_data['data_file'].file, enconding='utf-8')
reader = csv.DictReader(f)
for column in reader:
print(column['Customer Name'])
the error i get is:
utf-8' codec can't decode bytes in position 10-11: invalid continuation byte
Changed it to 'latin-1' (see comments) Gives error
line contains NULL byte
I dont have NULL values in my CSV file
The answer was:
f.readline()
the first line was empty