Subscribe Bookmark RSS Feed

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

robust1972

Community Trekker

Joined:

Jan 15, 2014

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

Staff

Joined:

Mar 21, 2013

Solution

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
3 REPLIES
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

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

Staff

Joined:

Mar 21, 2013

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

Staff

Joined:

Mar 21, 2013

More about JMP's zipArchive object: Load Compressed Data

Craige