-1

I have a problem loading a txt file from a Google drive to numpy. It got OSError. I put all the .py file and txt file in the same folder but it didn't work. I read through some similar topics and it seems like it may be because the file is made from OS user (if I understand correctly).

My code is just simple like this:

import numpy as np

data = np.loadtxt("weight_height_1.txt", delimiter=",")

Error message:

https://i.stack.imgur.com/dgOFJ.png
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Long Le\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\lib\npyio.py", line 1065, in loadtxt
    fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
  File "C:\Users\Long Le\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\lib\_datasource.py", line 194, in open
    return ds.open(path, mode, encoding=encoding, newline=newline)
  File "C:\Users\Long Le\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\lib\_datasource.py", line 531, in open
    raise IOError("%s not found." % path)
OSError: weight_height_1.txt not found.
edusanketdk
  • 602
  • 1
  • 6
  • 11
Vince
  • 1
  • Did you read the error message? "weight_height_1.txt not found." – Robert May 16 '21 at 15:14
  • Yeah I know it. The thing is the file with exact name is in the same working directory and the file exists. I am confused about why it says the file not found... Thanks Rob. – Vince May 17 '21 at 01:49

1 Answers1

0

You put the .txt file and .py file in the same directory, so the problem is most likely an error in the name.

Check if the txt file is named exactly weight_height_1.txt, Python is case-sensitive so care about capitalization!