Screen Link: https://app.dataquest.io/m/312/lists-and-for-loops/7/opening-a-file
My Code:
from csv import reader
opened_file = open('AppleStore.csv')
read_file = reader(opened_file)
apps_data = list(read_file)
print(len(apps_data))
print(apps_data[0])
print(apps_data[1:3])
What I expected to happen:
Show the length of the AppleStore table
Show the column names in the first row
Show the second and the third row
What actually happened:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-1-7d1dd4981329> in <module>
5
6 print(len(apps_data))
----> 7 print(apps_data[0])
8 print(apps_data[1:3])
IndexError: list index out of range
I think it was unable to read the AppleStore.csv file properly and only produce an empty set. Being frustrated, I literally copy/paste the answer and it still would not work. I tried it on a local machine and it does work as expected. Does this issue happen often in DataQuest? I’m still trying DataQuest out and I’m hesitated to pay for it now.