cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar

Save JMP file generated using import function to specific location with specific name.

I am importing multiple file from using import function. I want to save it automatically outside the folder and with same name.

ConfidenceOwl94_0-1738784402362.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Save JMP file generated using import function to specific location with specific name.

I assume you want to save files found from Sample Data folder into single JMP table named Sample Data.jmp which is on the same level as the folder.

Names Default To Here(1);

xlsx_dir = "$DOWNLOADS/JMP example/Sample data/";
dir = Convert File Path(xlsx_dir, posix);

dts = Multiple File Import( // will return a list
	<<Set Folder(xlsx_dir),
	<<Set Excel Best Guess(0),
	<<Set Excel Has Headers(0)
) << Import Data;


dt = dts[1]; // basically you should end up with just a single file

// drop 1 level lower in path
root_dir = Word([1 -2], dir, "/\") || "/";
foldername = Word(-1, dir, "/\");

dt << Save(root_dir || foldername || ".jmp");

Modify as needed, this provides some ideas on how to "traverse" the directory path using Word()

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Save JMP file generated using import function to specific location with specific name.

I assume you want to save files found from Sample Data folder into single JMP table named Sample Data.jmp which is on the same level as the folder.

Names Default To Here(1);

xlsx_dir = "$DOWNLOADS/JMP example/Sample data/";
dir = Convert File Path(xlsx_dir, posix);

dts = Multiple File Import( // will return a list
	<<Set Folder(xlsx_dir),
	<<Set Excel Best Guess(0),
	<<Set Excel Has Headers(0)
) << Import Data;


dt = dts[1]; // basically you should end up with just a single file

// drop 1 level lower in path
root_dir = Word([1 -2], dir, "/\") || "/";
foldername = Word(-1, dir, "/\");

dt << Save(root_dir || foldername || ".jmp");

Modify as needed, this provides some ideas on how to "traverse" the directory path using Word()

-Jarmo

Re: Save JMP file generated using import function to specific location with specific name.

Thanks for the explanation. I worked fine. 

 

I was able to get file name but was strugalling with saving it.

//File name=reverse(words(dir,"/"))[1];
//dt << Set Name(wafer);

jthi
Super User

Re: Save JMP file generated using import function to specific location with specific name.

Word(-1, str,) is basically same as Reverse(Words(str))[1]. Learning how to utilize both Word and Words can be very helpful (and sometimes Item and Items())

Names Default To Here(1);

my_str = "http://www.jmp.com";

r1 = Word(-1, my_str, ":/.");
r2 = Reverse(Words(my_str, ":/."))[1];

Show(r1, r2);
-Jarmo

Recommended Articles