Unable to list() csv file in Jupyter Lab

Hi!

I have recently finished Part 1 of the ‘Data Scientist in Python’ path. I have tried to upload my guided project to Jupyter Lab, where it has not behaved the same as it did in the Dataquest browser window.

In the lesson I completed it using Jupyter Notebook, but my previous experience of Python is with Jupyter Lab. Which I already have loaded to my computer. Therefore, I would like to be able to load the files/complete my work in Jupyter Lab rather than Jupyter Notebook.

I have simply written:

from csv import reader
open_file = open('AppleStore.csv')
read_file = reader(open_file)
data_list = list(read_file)

Here is a screenshot of my code and the error message.:

I apologise if this is a simple mistake, but I just can’t work out what is wrong! Especially as the file worked fine in the Dataquest browser window.

Many thanks in advance.

Hi @CharlieAT, welcome to the community!

Likely, you need to specify utf-8 decode as per this article – based on how the data is encoded (while still readable in csv format by excel), you might still need to do some decoding before using python to wrangle the data.

Hope this helps!

It worked! I had to edit my code to the following for it to work.

open_file = open('AppleStore.csv', encoding="utf8")

Many thanks for your help.

2 Likes