Reputation: 556
I am using Jupyter notebook to import some data from a text file.
The folder from which I have imported the notebook has another file, data.txt
but when I try to use the loadtxt()
module, the following error appears:
IOError Traceback (most recent call last)
<ipython-input-4-a129a96139d0> in <module>()
----> 1 our_data = loadtxt("data.txt")
IOError: data.txt not found.
I looked for a solution and the manual in the notebook stated that the file may not be in the same directory or folder as your notebook.
I checked twice and found that the folder on my computer contains both the notebook and the data.txt
file in the same location.
What is the issue?
Upvotes: 0
Views: 428
Reputation: 2683
The file is simply not in the folder of the output of this code
import os
print(os.getcwd())
You need to either put the data.txt
file in this folder or load the file with a path the points to the file.
Upvotes: 1
Reputation: 446
Can you try using a full path instead of just data.txt?
Maybe the current directory for jupyter is not where the notebook is.
Or you could try printing the current directory, or current directory contents like this to be sure:
import os;print(os.listdir("."))
Upvotes: 0
Reputation: 360
As far as I know, loadtxt()
method is from numpy
, so you should addimport numpy as np
and use it as np.loadtxt()
.
Hope this helps!
Upvotes: 0