Message Boards Message Boards

0
|
5664 Views
|
13 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Importing .csv files in Mathematica Online

Posted 2 years ago

Hi

I have just subscribed to Mathematica Online and for the pass couple of days going through the various tutorials. However, when it comes to importing data I have hit a huge roadblock. Appreciate any guidance I can get.

Thanks and regards

13 Replies

Hi,

your example will look for "Variables.csv" only this file will be listed if it exists and no other will be listed.

Perhaps you intended:

FileNames["*.csv", Folder] 

Robert

POSTED BY: Robert Nowak
Posted 2 years ago

On the desktop and cloud this should work.

FileNames["*.csv", Folder]
POSTED BY: Rohit Namjoshi

Hi Robert/Rohitji

Thank you for taking the time to reply. Unfortunately, the results did not come out as expected (Please see attached). Not sure if it's of any use, but I'm using a Mac.

Regards,

Arasan

Attachments:

Hi Arasan

I have only two explanations for you:

  1. the folder does not contain any .csv files

  2. the folder spec is wrong

If I try it on an non existing Folder I also get an empty List:

FileNames["*", "Blabla"]
(* { } *)

Robert

POSTED BY: Robert Nowak

The suggestions from Rohit and Robert work on the desktop version of Mathematica. I do not think you can access your filesystem from Wolfram Cloud. I just tried it from my Mac and I also get an empty list. However, I can see my cloud files on the right hand side of the screen. I can access those files and that file structure using FileNames[".", Folder].

Try typing FileNames[] and you should get all the files in the Wolfram Cloud Home directory. You can dive down from there. To move your .CSV files there, you can drag and drop them into Home or a Folder.

Regards

Neil

POSTED BY: Neil Singer

Thanks for the quick feedback Robert

As you can see from the screenshot the folder does contain .csv. files. On the folder specs are you referring to the path? Not sure if I understand you correctly.

Thanks

Arasan

Thank you Neil, it now puts to bed to my search on how to access my filesystems via the Online version. So the only option is via the cloud files and I can see the folders in the Cloud Home Directory as per the method you suggested. However, I am not able to import the csv files in the cloud folders. Any idea how this can be done. I tried Import with the filename.csv and specifying the folder within the cloud that has the file but it returned "file not found during import". Please see attached.

Thanks and regards

Arasan

Attachment

Attachments:

I was able to bring up a finder window and drag the files from the Mac to the home directory on the right hand side of the browser window (the region just below where the image below cuts off. Alternatively, there is an upload files button on the top of the right hand side -- highlighted in blue below.

enter image description here

Regards

Neil

POSTED BY: Neil Singer

Thanks Neil, Perhaps I was not clear on the 2nd part of my question. Now that the files are in the cloud, how do you import them into Mathematica Online? As you can see I have tried importing them from the cloud but it returns an error that the file is not found when it is in fact on the cloud. What am I missing here?

Ah!,

Your problem is Copied Files is a string -- you need quotes around it. You also need a proper full path to the file. You can do something like this (or type the full file name):

myfile = FileNames["Copied Files/Var*.CSV"]

and your file will be found.

data = Import[myfile]

Regards,

Neil

POSTED BY: Neil Singer

Thanks Neil, unfortunately it's still showing an error. Please see below.

enter image description here

I had a typo, you need to grab the first (and only element) in the list:

Import[myfile[[1]]]

or do

Import["Copied Files/Variables.csv"]

Regards

POSTED BY: Neil Singer

Fantastic! It works now. Thank you very much Neil. Have a good weekend.

Regards,

Arasan

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract