I keep getting a error message when I try to import something the directory path just will not work even with Insert Path. This is a big pain. What is happening I have no idea how to fix this problem and I cannot share the entire path because it will reveal my computer name. What can i do??
I can’t do anything! To figure out so many things on programming because they are not obvious in the connection to language. They are “invisible”.
Which command are you trying to use? Import? Get? Read? There is no InsertPath command, so what do you mean that it doesn’t work with “Insert Path”?
It would be pretty easy to elide the computer name when you post the actual command you are trying to run, and seeing what you’re actually trying would make it a lot easier to help.
I got a syntax Error , I tried it again and it worked. I did not need backslash for spaces in the path. That was what I did first but second time I used the Menu bar to insert a file path. see below. That still did not work. I don’t know why I must have made a change somehow. I tried it twice and it worked.
I mean on the top of the menu bar, “Insert” scroll down to the end to “File Path..” I used that to select the file to Import.
Glad you figured out something that worked. For future reference, you might try…
Use the File Browser tool. If you type Import[, that should automatically create the close brace, so you’ll have Import[] with the cursor between the braces. Now type " and it should automatically insert the close quotes, and you’ll have Import[""] and also a little tooltip kind of thing that says “File Browser”. Click on “File Browser” and you can navigate to the file you want. [I’m using version 14, but this functionality has existed for awhile, although I’m not sure exactly which versions support it.]
Use FileNameJoin. Rather than try to figure out the directory delimiters and escape characters yourself, let this function build the path name for you. So, some thing like Import[FileNameJoin[{$RootDirectory, "Users", "bob", "Desktop", "the photo.png"}]].
Use specially defined paths. If the file you want to import is in the same directory as the notebook you’re working in, you can do this: Import[FileNameJoin[{NotebookDirectory[], "the photo.png"}]]. There are other defined constants, e.g. $HomeDirectory.