cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

How do I select files and create the pathway to it as a string?

anders_bankefor
Level III

Hi,

I would like to create a function that enables me to pick multiple files, retrive the local pathway to them and then store this pathway as a string in order to import them to JMP.

dtname = {};

dt.file = Pick File (...);

//select the dir.

path = Pick Directory ("Select a directory.");

for (i=1, i<= N Items(dt.file), i++,

//String of my file name

dtname = dt.file << Get Name ;

Open (

path||"\"||dtname,

//the import settings should predefine which row is header, new column etc.

Import Settings(..)

)

)

when executing this I get a return message that says "Send Expects Scriptable Object in access or evaluation of 'List*...."

What am I doing wrong? Do I have to eval my dt.file = Pick File (...); function?

1 ACCEPTED SOLUTION

Accepted Solutions
msharp
Super User (Alumni)


Re: How do I select files and create the pathway to it as a string?

You can open multiple files with pick file().  You can also specify the excel import options right in open().  Look at Open() in the Scripting Index, example 2.

file = Pick File("Pick a file", "$DOCUMENTS", {"Excel|csv;xlsx;xls","JMP Files|jmp;jsl;jrn", "All Files|*"}, 1,0, "", multiple);

For(i=1, i<=nitems(file), i++,

       Open(file[i], /*excel options ie: ,Table Contains Column Headers( 1 ), Column Names are on line (3), ect.*/)

);

View solution in original post

3 REPLIES 3
ms
Super User (Alumni) ms
Super User (Alumni)


Re: How do I select files and create the pathway to it as a string?

Pick File() by default returns file name, including the path to the file, as a string.

This should work:

dt.file = Pick File();

Open(dt.file)

anders_bankefor
Level III


Re: How do I select files and create the pathway to it as a string?

Hi MS and thank you for your quick reply.

yes this is exactly what I thought since I can use dt.file << Get Name;

I can see now that I've made an error in my discussion, dt.file should be a list so that I may stack several csv files. Therefore I need to iterate/recursively go through the list and import the excel file to JMP.

Moreover, I would like to use "import settings(...)" to predefine the parameters for importing data to JMP, if I use open I have to define these parameters manually for each file that I import.

I've corrected my original post and I look forward to your reply.

BR

Anders

msharp
Super User (Alumni)


Re: How do I select files and create the pathway to it as a string?

You can open multiple files with pick file().  You can also specify the excel import options right in open().  Look at Open() in the Scripting Index, example 2.

file = Pick File("Pick a file", "$DOCUMENTS", {"Excel|csv;xlsx;xls","JMP Files|jmp;jsl;jrn", "All Files|*"}, 1,0, "", multiple);

For(i=1, i<=nitems(file), i++,

       Open(file[i], /*excel options ie: ,Table Contains Column Headers( 1 ), Column Names are on line (3), ect.*/)

);