I searched through the python csv questions, can't seem to find anything addressing the reader error I'm getting.
I have a csv file with 6 columns, trying to access two of them:
import csv
with open('/home/conjugater/Downloads/aapl.csv', newline='') as csvfile:
dialect=csv.Sniffer().sniff(csvfile.read(1024))
csvfile.seek(0)
reader=csv.reader(csvfile, dialect)
for row in reader:
for Date, Open, High, Low, Close, Volume in row:
print(Date, Close)
I'm not done coding, but this is my first time using the csv module and I'm just trying to get a feel for it (relatively new to python in general).
Traceback (most recent call last):
File "reader.py", line 8, in <module>
for Date, Open, High, Low, Close, Volume in row:
ValueError: need more than 5 values to unpack
I can get the columns I want with
for row in reader:
print(row[0], row[4])
but I know there's a way to assign each column a name with python as well; any help much appreciated.