cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

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