cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Stokes
Level IV

How to save a file with name as a variable in For loop to save multiple files

Hi, I am trying to save files in a for loop, the problem is how to put a variable into the file saving procedure,

However, it looks the file save part is not working.

I didn't use any clear global to make sure filename has be assigned with the original value.

Is there any problem with my saving part?

Thanks

 

 

// filename is a variable assigned below,
For( j = 1, j <= N Row( sdt ), j++,
filename = Column( sdt, "file" )[j];
Close( Data Table( sdt ), No Save );

// During saving the file, the directory is fixed, however the filename is an variable, 
// the goal is to use the left(filename,18) and concatenate with "_Type1" in the file name. dt1 = Current Data Table(); dt1 << save( "C:\Users\file\JSL\"||Right( filename,18)||"_Type1.csv" );



2 REPLIES 2
Mauro_Gerber
Level V

Re: How to save a file with name as a variable in For loop to save multiple files

Hi

I chanched the code a bit so this may help:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

path = "C:\Users\file\JSL\"


For( j = 1, j <= N Row( dt ), j++,
	dt << save as (path || dt:name[j] || "_Type1.csv" );
);

It can be that you need to do a  "save as" to make it work.

"I thought about our dilemma, and I came up with a solution that I honestly think works out best for one of both of us"
- GLaDOS
Stokes
Level IV

Re: How to save a file with name as a variable in For loop to save multiple files

Hi, Thanks a lot.

It works now.

Recommended Articles