cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
robust1972
Level IV

how to save .csv and zip/compress the csv file with jsl

hi, all

anyone know how to save .csv and zip/compress the csv file with jsl? Is it possible at all?

thanks!

Evan

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: how to save .csv and zip/compress the csv file with jsl

dt = Open( "$sample_data/big class.jmp" );

dt << save( "$temp/deleteme.csv" ); // create a temporary CSV

csvtxt = Load Text File( "$temp/deleteme.csv" ); // and load it as text

ziparchive = Open( "$temp/deleteme.zip", "zip" ); // open a new or existing ZIP

Show( ziparchive << dir ); // old members

actualname = ziparchive << Write( "bigclass.csv", csvtxt ); // add new member

Show( ziparchive << dir ); // the new name may change if conflict

restore = ziparchive << read( actualname, Format( blob ) ); // read the new member

path = Save Text File( "$temp/deleteme2.csv", restore ); // put back on disk

Open( path ); // finish the round-trip by opening

Craige

View solution in original post

3 REPLIES 3
Craige_Hales
Super User

Re: how to save .csv and zip/compress the csv file with jsl

dt = Open( "$sample_data/big class.jmp" );

dt << save( "$temp/deleteme.csv" ); // create a temporary CSV

csvtxt = Load Text File( "$temp/deleteme.csv" ); // and load it as text

ziparchive = Open( "$temp/deleteme.zip", "zip" ); // open a new or existing ZIP

Show( ziparchive << dir ); // old members

actualname = ziparchive << Write( "bigclass.csv", csvtxt ); // add new member

Show( ziparchive << dir ); // the new name may change if conflict

restore = ziparchive << read( actualname, Format( blob ) ); // read the new member

path = Save Text File( "$temp/deleteme2.csv", restore ); // put back on disk

Open( path ); // finish the round-trip by opening

Craige
Craige_Hales
Super User

Re: how to save .csv and zip/compress the csv file with jsl

the last two lines can be simplified:

open(restore,"text");

The blob data from the ziparchive object can be opened directly with the "text" argument.

Craige
Craige_Hales
Super User

Re: how to save .csv and zip/compress the csv file with jsl

More about JMP's zipArchive object: Load Compressed Data

Craige