1
$\begingroup$

I don't know why I can't get my files to import from my flashdrive into my notebook.

I have .mat files and .cvs files.

I've tried this

Import["/LocalDisk(E:)/MOptics/imagedata1.mat"]

and this

Import["/Computer/LocalDisk(E:)/MOptics/imagedata1.mat"]

and this

Import["/Computer/LocalDisk/MOptics/imagedata1.mat"]

and this for the cvs

Import["/LocalDisk(E:)/MOptics/sun1.csv"];

with the same variations as above.

LocalDisk(E:) is the flashdrive and MOptics is the folder.

$\endgroup$
  • $\begingroup$ What operating system are you on? $\endgroup$ – Jinxed Apr 10 '15 at 17:22
  • $\begingroup$ windows paths look like: "E:\\MOptics\\..." (single forward slash should work as well ) $\endgroup$ – george2079 Apr 10 '15 at 17:28
  • $\begingroup$ Windows. I am working on a school computer so I was trying to import them off a P drive at first which it didn't like either $\endgroup$ – Marina Koepke Apr 10 '15 at 17:28
  • $\begingroup$ "E:\\MOptics\\. didn't work $\endgroup$ – Marina Koepke Apr 10 '15 at 17:31
  • $\begingroup$ What Mathematica is this? 10? $\endgroup$ – Jinxed Apr 10 '15 at 17:32
3
$\begingroup$

Here is what worked in my case:

First open a new notebook.

Save it to your flashdrive, into the same folder where your "csv" files are located.

type in:

NotebookDirectory[]

Out:

/Volumes/TRANSCEND/MOptics/

Now you know exactly how the filename is represented in your system. I am on a mac, thats why my filenameSeperators are represented as "/". Go to your notebook located at your harddrive and type in:

dir = "/Volumes/TRANSCEND/MOptics/";
Import[FileNameJoin[{dir,"sun1.csv"}]

Its practical to save your SD-directory to a variable and use FileNameJoin. FileNameJoin is OS-independent and uses automatically the correct filenameseparator for your system.

EDIT:

completely system-independent solution:

Get a directory list from your folder located at flashdrive:

dirList = FileNameSplit[NotebookDirectory[]]

Out:

{"", "Volumes", "TRANSCEND","MOptics"}

Importing a File from hdd:

dirList = {"", "Volumes", "TRANSCEND", "MOptics"};
Import[FileNameJoin[Append[dirList, "sun1.csv"]]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.