Guided project 1. Step 2. Opening and exploring file

Hello, I’m just trying to explore the two files I opened for the first guided project. But, it seems something is wrong. I’m trying to complete this assignment in my own notebook, so not in the DataQuest jupyter notebook generator and attempted to put the file path instead of the name of the file, but I still don’t get the expected results.

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:

from csv import reader

## opening googleplaystore file
opened_file = 'googleplaystore.csv'
read_file = reader(opened_file)
android = list(read_file)
android_header = android[0]

## opening Applestore file
opened_file = 'AppleStore.csv'
read_file = reader(opened_file)
ios = list(read_file)
ios_header = ios[0]


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(android_header)
print('\n')
explore_data(ios, 0, 3, True)

What I expected to happen:

[‘App’, ‘Category’, ‘Rating’, ‘Reviews’, ‘Size’, ‘Installs’, ‘Type’, ‘Price’, ‘Content Rating’, ‘Genres’, ‘Last Updated’, ‘Current Ver’, ‘Android Ver’]

[‘Photo Editor & Candy Camera & Grid & ScrapBook’, ‘ART_AND_DESIGN’, ‘4.1’, ‘159’, ‘19M’, ‘10,000+’, ‘Free’, ‘0’, ‘Everyone’, ‘Art & Design’, ‘January 7, 2018’, ‘1.0.0’, ‘4.0.3 and up’]

[‘Coloring book moana’, ‘ART_AND_DESIGN’, ‘3.9’, ‘967’, ‘14M’, ‘500,000+’, ‘Free’, ‘0’, ‘Everyone’, ‘Art & Design;Pretend Play’, ‘January 15, 2018’, ‘2.0.0’, ‘4.0.3 and up’]

[‘U Launcher Lite – FREE Live Cool Themes, Hide Apps’, ‘ART_AND_DESIGN’, ‘4.7’, ‘87510’, ‘8.7M’, ‘5,000,000+’, ‘Free’, ‘0’, ‘Everyone’, ‘Art & Design’, ‘August 1, 2018’, ‘1.2.4’, ‘4.0.3 and up’]

What actually happened:

[‘g’]

[‘A’]

[‘p’]

[‘p’]

Number of rows: 14
Number of columns: 1

@jonathandeleon, welcome to the community!

In the first line of your code, you simply assigned the string "googleplaystore.csv" to the variable opened_file.

To open your googleplaystore file, you use this line of code: opened_file = open('googleplaystore.csv') and also for your Applestore file, you use opened_file = open('AppleStore.csv').

Generally, The open() built-in function opens a file, and returns it as a file object, you can read more about the open() built-in function here.

I hope this helps.

2 Likes

Ah, so simple I probably should have done one more look over before posting, thank you!

@jonathandeleon,

You are welcome. If the reply solves your problem, kindly mark it as a solution so that when other members of the community comes to this topic with the same question, they would easily see the solution for it.

Good luck and Happy learning!