0

I have a code in which I am loading a text file from a folder. The code looks like this:

snap1 = np.loadtxt("../data/milli_17")
snap2 = np.loadtxt("../data/milli_19")

So the milli17 and milli19 files are located in a folder that is located in the same folder with my working folder. So far everything was good. However, I moved the data folder inside the working directory so the directory placement became like this: /Workingdirectory/data/

So I went ahead and reflected that on the code by removing the two dots so it wouldn't go up one directory:

snap1 = np.loadtxt("/data/milli_17")
snap2 = np.loadtxt("/data/milli_19")

However now when I run the code I get an error saying the directory does not exist:

IOError: [Errno 2] No such file or directory: '../data/milli_17'

but debugging shows the line of error as this:

----> 4 snap1 = np.loadtxt("/data/milli_17")

Couldn't get my head around it, all seemed OK to me. Where do I make the mistake?

Edit: I don't think the problem has something to do with how I write down the path. The problem is that it doesn't matter what I put there, the code still (as seen in the error code) goes and checks the old directory.

2
  • give the path like this: np.loadtxt("./data/milli_17"); same for the other Commented Jan 17, 2016 at 23:21
  • Yep changed, but still the same error. Commented Jan 17, 2016 at 23:31

2 Answers 2

1

If you restart the kernel that should resolve your issue.

Sign up to request clarification or add additional context in comments.

Comments

0

I believe you have to use the file extension and no forward slash before the data folder.

snap1 = np.loadtxt("data/milli_17.txt")

1 Comment

The text file itself does not have an extension. It is just milli_17. At first, I wrote the path without the slash and it didn't work either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.