My code.
def import_excel(request):
if request.method == 'POST':
person_resource = PersonResource()
dataset = Dataset()
new_person = request.FILES['myfile']
if not new_person.name.endswith('csv'):
messages.info(request,'Wrong format')
return render(request,'upload.html')
imported_data = dataset.load(new_person.read(),format='csv')
for data in imported_data:
value = Person(
data[0],
data[1],
data[2]
)
value.save()
return render(request,'upload.html')
While importing the CSV file to the database getting the error like this:
iterator should return strings, not bytes (the file should be opened in text mode)