cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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

Recommended Articles