'utf-8' кодек не может декодировать байт 0x89 в позиции 0: недопустимый начальный байт '
как решить эту ошибку? "'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte ' . while uplaoding csv file in django. Здесь функция просмотра
def upload_csv(request):
template = "upload_csv.html"
if request.method == "GET":
return render(request,template)
csv_file=request.FILES['file']
if not csv_file.name.endswith('.csv'):
messages.error(request,'This is not a csv file')
data_set = csv_file.read().decode('UTF-8')
io_string =io.StringIO(data_set)
next(io_string)
for row in csv.reader(io_string,delimiter=',',quotechar="|"):
_, created = Company.objects.update_or_create(
name = row[0],
hr_name =row[1],
hr_email=row[2],
hr_verified=row[3],
user_id=row[4],
primary_phone=row[5],
comments=row[6],
)
context={}
return render(request, template,context)