Getting Type error while opening an uploaded CSV File Getting Type error while opening an uploaded CSV File django django

Getting Type error while opening an uploaded CSV File


This works for Python 3

import csvimport io...csv_file = request.FILES['uploadFile']decoded_file = csv_file.read().decode('utf-8')io_string = io.StringIO(decoded_file)for line in csv.reader(io_string, delimiter=';', quotechar='|'):    print(line)


No need to call open on the file, it's already open. You should be able to pass it straight into the DictReader.


open() takes the name of the file as the argument and not the file object itself.

Can you try something like this:

paramFile = request.FILES['uploadFile'].read()portfolio = csv.DictReader(paramFile)