Message Boards Message Boards

Code to browse and select a file and import the .txt or .cvs data?

This is very simple but not able to do it .

I am developing a code where I need to find a file from a directory on a computer. I want the function that will provide the bottom to BROWSE and select a file and import the .txt or .cvs data into the notebook.

I am not sure how to get this started. I have a .CVX and a .txt file with a table of data that I will like to import into current notebook using a data name.

Please help.

Jose E. Calderon

POSTED BY: Jose Calderon
Posted 8 years ago

You can insert a file name at the cursor by using the top menu Insert > File Path. You can also open a browser, select a file name, and assign it to a variable like this:

In[11]:= fileName = SystemDialogInput["FileOpen"]

Out[11]= "C:\\Users\\David\\Documents\\Mathematica \
files\\Ellipsoid\\Ellipsoid 1_1.nb"

This assigns a selected file name with full path to a variable, which can then be used to Import the file.

Here is another method. Evaluating this opens a browser and sets the variable f (or any other) to the selected path:

{FileNameSetter[Dynamic[f]], Dynamic[f]}
POSTED BY: David Keith
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