Reputation: 29
I am trying to do a simple csv read for my code and it has worked up until I tried tonight for Mac. Currently on 10.15.3, Catalina. This is my code:
df = pd.read_table('/Users/nicholasmori/Desktop/FINAL.csv', delimiter=',')
And the error it gave me was:
OSError: Initializing from file failed.
Ive tried multiple different options to read this csv, including
pd.read.csv(open( ) )
csv.reader( )
pd.read_csv()
with open ( ) as csvfile:
But all these give similar errors. I am sure theres a simple answer, but I haven't been able to find it. Ive tried the
sudo chown username:group filename
command on terminal, and allowed terminal access through my privacy/firewall settings. My file also has Read & Write permissions for "everyone," unless I'm viewing that wrong. Does anyone have a solution for me?
Upvotes: 0
Views: 547
Reputation: 3001
When did you upgrade from macOS Catalina (10.15.x) from a previous version (10.14)? OS-level access rights are a bit different.
Also, you can try this, to verify that the file (and path, if provided) are correct:
from pathlib import Path
file_name = 'test.npy'
Path(file_name).is_file() # returns True or False
print(Path.cwd()) # prints current working directory
Upvotes: 0
Reputation: 11
I had the same error, what I did was upload the file to jupyter from my Mac (same root of the python program) and:
import pandas as pd
path_file = "FileName.csv"
data = pd.read_csv(path_file)
Hope works!
Upvotes: 1