How can I fix this File Error in my Program

43 Views Asked by At

I found this error while coding:

FileNotFoundError: [Errno 2] No such file or directory: 'us_baby_names' 

please how can I fix this?

Us_baby_names is the name of my dataset file.

I have tried moving the file using the

mv dataset function

And also

Specifying the path of the file as

data = of.read_csv("/path/to/dataset", encoding="ISO-8859-1")

and I got a

SyntaxError: (Unicode error) 'codec can't decide bytes in position 3-4: truncated
2

There are 2 best solutions below

0
On

Try adding to your read_csv function:

encoding_errors='ignore'
0
On

I was able to solve the problem with the line of code above.

I discovered that, there was another copy of the same dataset "us_baby_names" in same directory.

I removed all the existing dataset having same name from the directory.

Then run the code again and the problem cleared.

Thank you all.