1

What am I doing wrong here?

I cannot add a path to my Jupyter Notebook. I am stuck. Any of my attempts did not work at all.

home_dir="\C:\Users\User\Desktop\" data_dir=home_dir + "\C:\Users\User\Desktop\A Student's Guide to Python for Physical Modeling by KInder and Nelson\code" data_set=np.loadtxt(data_dir + "HIVseries.csv", delimiter=',')

1
  • \C:\Users\User\Desktop\A Student's Guide to Python for Physical Modeling by KInder and Nelson\code is an absolute file path, adding another root dir prefix makes it invalid. Commented Feb 15, 2017 at 3:25

2 Answers 2

1

It's easy question, modify \C:\Users\User\Desktop\A Student's Guide to Python for Physical Modeling by KInder and Nelson\code to C:\\Users\\User\\Desktop\\A Student's Guide to Python for Physical Modeling by KInder and Nelson\\code.

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

1 Comment

Sorry, but my attempt to add "\\" did not work out. Thanks for your answer tho!
0

Change the second line of your code as:

home_dir = "\C:\Users\User\Desktop\"
data_dir = home_dir + "A Student's Guide to Python for Physical Modeling by KInder and Nelson\code"
data_set = np.loadtxt(data_dir + "HIVseries.csv", delimiter=',')

Your code adds the home directory to the data directory. You don't to include the home again. Just providing the relative path would work.

What you were doing would make data_dir equal to \C:\Users\User\Desktop\\C:\Users\User\Desktop\A Student's Guide to Python for Physical Modeling by KInder and Nelson\code which is not a valid path.

Comments

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.