Code was working fine 2 weeks ago and now I’m getting this error message, which I have no idea what it means??
I just got this error a few hours ago myself while trying to read in a file. Try adding
encoding=Latin-1 to your
open function. What this error means is that your file is not encoded as
UTF-8 so it’s time to try the other common encoding.
Latin-1 is one of them.
Windows-1251 is another one. Refer to the Data Cleaning Basics mission in Pandas and Numpy Fundamentals. This is discussed a while in that mission.
Hi Yemi, where would you add this within the function? I am getting positional argument invalid syntax and name errors.
I should have been more explicit, shouldn’t I?! Sorry! Okay. Say I am opening a file located in my working directory named
file.csv. I would do this:
f = open('file.csv', encoding='Latin-1'). So you will just have to add a comma in your
open function and add the encoding like I did in my example.
No problem at all, it worked!!! You’re a legend.
I am unable to reproduce this. Can anyone who has this problem share the file in question?
I also am unable to get this to work.
encoding Latin-1 now gets another error:
Error Traceback (most recent call last)
11 opened_file = open(‘AppleStore.csv’, encoding=‘Latin-1’)
12 read_file = reader(opened_file)
—> 13 ios = list(read_file)
14 ios_header = ios
15 ios = ios[1:]
Error: line contains NULL byte
Never mind, I figured it out. I saved the Notebook and re-opened and it worked! Thank you.
Hi Maria Angel! Thanks for tagging me… Let me see. Are you working locally or on Dataquest? And which mission is this?
In the meantime, let’s try this when you open the file:
opened_file = open(‘AppleStore.csv’, 'rb', encoding=‘Latin-1’)
Thank you for responding. I’m working on mission 350 which is the apps data for GooglePlay and AppleStore data.Untitled.ipynb (18.9 KB)
Using your tip on encoding=‘Latin-1’ I got the file to read in. Thanks for great tip!
So the NULL byte error you were getting is now solved?
Yes. Thanks again Yemi. Really appreciate your responding.
Yay!!! And no problem! That’s why I am here! Do you mind marking my answer as the solution so anyone who stops by can quickly scan the thread for the answer? To do so, right below my answer, click on the three dots
... next to
Reply and then click on the
square with the check mark inside. Thank you Maria Angel!
Sorry not able to mark as solution.