Guided Project 1. Step 2. Exploring File Output Does Not Look Right

Hi, I am attempting GP 1. I tried to explore the data of the App Store and the output does not look correct to me. Can someone review my code?

Thanks

Screen Link:
https://app.dataquest.io/m/350/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets/2/opening-and-exploring-the-data

My Code:

# App Store data set #
opened_file = ('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
ios = list(read_file)
ios_header = ios[0]
ios = ios[1:]


# Google Play data set #
opened_file = ('googleplaystore.csv')
from csv import reader
read_file = reader(opened_file)
android = list(read_file)
android_header = android[0]
android = android[1:]

def explore_data(dataset, start, end, rows_and_columns=False):
    dataset_slice = dataset[start:end]
    for row in dataset_slice:
        print(row)
        print('\n') 
        
    if rows_and_columns:
        print('Number of rows:', len(dataset))
        print('Number of columns:', len(dataset[0]))
              
print(ios_header)
print('\n') 
explore_data(ios, 0, 3, True)


What I expected to happen: To see the ios header row, followed by an empty line, then see data that corresponds to the first three rows of data of the App Store data set.

What actually happened:

['A']


['p']


['p']


['l']


Number of rows: 13
Number of columns: 1

You did not use open to open the file.

Your code:

opened_file = ('AppleStore.csv')

How it should be:

opened_file = open('AppleStore.csv')
2 Likes

@otavios.s, Thanks you very much! Iā€™d stared at it over and over again and I completely missed my omission of open(). Your fresh set of eyes saw it immediately.

Thanks again!

1 Like