Guided Project: Profitable Apps | Trouble recalling list items

I’ve been following the guided project and have run into some unexpected behaviour with my code.

I’ve assigned the Google Play Store data to a list, but when trying to recall an item in a row, only the first character is returned:

def explore_data(dataset, start, end, rows_and_columns=False):
    dataset_slice = dataset[start:end]    
    for row in dataset_slice:
        print(row)
        print('\n') # adds a new (empty) line after each row

    if rows_and_columns:
        print('Number of rows:', len(dataset))
        print('Number of columns:', len(dataset[0]))

def open_file(file):
    opened_file = open(file)
    from csv import reader
    read_file = reader(opened_file)
    data_list = list(opened_file)
    file_data = data_list[1:]
    file_headers = data_list[0]
    return file_headers, file_data

google_headers,google_data = open_file('googleplaystore.csv')

len(google_data)

explore_data(google_data,0,10841)

first_name = google_data[0][0]

print(first_name)

The output of print(first_name) is P, and the same happens any time I try to retrieve item [0] from a row. Trying to retrieve later items also brings back the nth character in the row, rather than the item.

Can anyone help me with what I’m doing wrong?

Have you wondered what does open() return? What does the reader method in csv built-in module do?
You can do print() on their outputs to see what type of object they are, and learn more about how to interact with them.

A hint: in def open_file, why did you create the read_file variable but never used it?

Aha! Thank you! I couldn’t spot it for trying. :slight_smile: