I am reading csv file through upload and trying to store all values in a list
def upload(request):
paramFile = request.FILES[\'file\'].read()
data =
This should work if you're using Python 3.
file = request.FILES['file']
decoded_file = file.read().decode('utf-8').splitlines()
reader = csv.DictReader(decoded_file)
for row in reader:
# Get each cell value based on key-value pair.
# Key will always be what lies on the first row.
We can use the list that splitlines()
creates. splitlines()
is called because csv.DictReader
expects "any object which supports the iterator protocol and returns a string each time its next() method is called — file objects and list objects are both suitable".