I’m using Mathematica v9 Home Edition on an iMac. I’ve tried
data = Import["Desktop:sampledata.xlsx", {"Data", 1}]
and
data = Import["sampledata.xlsx", Path->"Desktop:",{"Data", 1}]
as well as other variants including the name of my iMac followed by a single colon or a double colon at the beginning of the path or the filename when I don’t use a path.
No matter which way I go, Mathematica always gives me
Import::nffil: File not found during Import.
Another question, which is possibly more a Mac question than a Mathematica question, is how I can get the complete file specification without typing all the characters myself. Surely there’s some Finder shortcut that will give me that character string after I click on the file name.
Thanks, Markus. When I select the file in the Finder and use “cmd+i”, I get an Info box. The box does have a “Name & Extension” component containing the text string “sampledata.xlsx” which I can copy and paste. The Info box also has a “General” component with other information about the file including “Where: /Users/store/Desktop” and I also can copy Where’s text string.
In Mathematica, I tried
data = Import[“/Users/store/Desktop/sampledata.xlsx”, {“Data”, 1}]
which worked perfectly. I also tried
data = Import[“sampledata.xlsx”,
Path → “/Users/store/Desktop”, {“Data”, 1}]
giving me “Import::argt: Import called with 3 arguments; 1 or 2 arguments are expected.” I got the same error with
data = Import[“sampledata.xlsx”,
Path → “/Users/store/Desktop/”, {“Data”, 1}]
I’d prefer to use the Path option, but I obviously don’t know the syntax Mathematica requires for a path specification.
As described in the Mathematica help under “Import” you can define a filename including file path and if needed an additional option to import the specified elements from the file.
If you want to define path and filename independent which is sometimes useful you can do it like this:
myPathName = "/Users/iMacName/Desktop/";
data = Import[FileNameJoin[{myPathName, "sampledata.xlsx"}], {"Data", 1}]
It might be also useful to take a look in the help to Directories & Directory Operations