Nov-04-2019, 08:25 PM
I'm very early on in python, but I'm trying to process a csv file with this code:
Thanks
K
# importing csv module import csv # csv file name filename = "admitOrders.csv" # initializing the titles and rows list fields = [] rows = [] # reading csv file print('\nKGG - First 5 rows are:\n') with open(filename, 'r') as csvfile: # creating a csv reader object csvreader = csv.reader(csvfile) # extracting field names through first row fields = csvreader.next()I'm getting this error:
Error:Traceback (most recent call last):
File "processCSV.py", line 18, in <module>
fields = csvreader.next()
AttributeError: '_csv.reader' object has no attribute 'next'
Any suggestions?Thanks
K