-4

File Not found when i should already copy that file to the directory

I already tried to copy that file in various folders like Include etc

import numpy as np
import collections
a=np.genfromtxt('Desktop\a.csv',delimiter=',',dtype=str)
print(a)

All the data that is in the file

Sociopath
  • 13,068
  • 19
  • 47
  • 75

1 Answers1

2

\a is an escape sequence like \n. In this case, it is the BEL character. Escape the backslash (\\a), use a raw string to suppress escape code translation (r'Desktop\a.csv') or use forward slashes.

Note you are also using a relative path, meaning you have to run the code from the directory in which "Desktop" is a sub-directory. Use a full path to make sure you get it on the desktop, which will include your username like 'c:/users/garauv/desktop/a.csv' or whatever your real username is.

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251