0

I've recently installed Linux Mint 20 on my machine. I wanted to continue with my project, but I keep getting an error:

FileNotFoundError: [Errno 2] No such file or directory: 'data.csv'.

I am trying to read a file, called 'data.csv', that is in the same folder as the python script. I had no issues on Windows 10, but now it keeps giving me this issue. This is my code:

import pandas as pd
df = pd.read_csv("data.csv")

I also tried using "./data.csv" instead, since "." refers to the current directory, but it didn't help me.
Can anyone explain me why and how can I fix this?
It works if I type in the absolute path, but is there away to make it work with the relative path?

Daniel
  • 487
  • 4
  • 11
  • The usual beginner error is to assume that the program switches to a different directory when you run it. If you think about it for a second or two, that would make it impossible to get a directory listing of your current working directory. – tripleee Nov 01 '20 at 18:51
  • 1
    Relative path works fine, too. But the path is relative to the current directory of the caller, not the script. – stark Nov 01 '20 at 19:28

1 Answers1

0

You can try to run it by typing the full directory path and see if it works.

dorukr0t
  • 55
  • 1
  • 8