Klue Klue - 1 year ago 243
Python Question

URLError: urlopen error [Errno 2] No such file or directory

I was perfectly able to use pandas

for reading files in Windows. However I cannot figure out how to set local path in Ubuntu?

If I do this:

data = pd.read_csv(r'file://home/gosper/Desktop/test.csv')

... it throws the error:
URLError: <urlopen error [Errno 2] No such file or directory

Answer Source

this should work for Windows's and UNIX's Desktop folder:

data = pd.read_csv(os.path.expanduser('~') + '/Desktop/test.csv')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download