BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
ambs
Community Trekker

JSL for exporting/saving JMP Data Table as a CSV file without saving the Column Headers

Hi Experts!

I need some help on some JSL, as stated in the subject of the discussion:

JSL for exporting/saving JMP Data Table as a CSV file without saving the Column Headers

Appreciate the help.

Thanks in advance!

regards,

ambs

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User ms
Super User

Re: JSL for exporting/saving JMP Data Table as a CSV file without saving the Column Headers

There are text export preferences that can be set to exclude headers and save as a comma-delimited file. Many prefs can be set by JSL but not all.

 

This JSL code works on Macintosh but should work on Windows as well (not tested). The code restores the original prefs after saving. However, if that's not important the script can be simplified.

 

 

dt = Current Data Table();
// Get current prefs
current_pref = Char( Arg( Parse( (Char( Get Preferences( Export settings ) )) ), 1 ) );
// Set prefs (comma delimited, no headers)
Pref( Export Settings( End Of Field( Comma ), Export Table Headers( 0 ) ) );
// Save csv file
If(
          Host is( Windows ), dt << save( "c:/mydata/test.txt" ),
          Host is( Macintosh ), dt << save( "test.csv", text )
);
//Restore oribinal prefs
Eval( Parse( "pref(" || current_pref || ")" ) );

 

4 REPLIES 4
ms
Super User ms
Super User

Re: JSL for exporting/saving JMP Data Table as a CSV file without saving the Column Headers

There are text export preferences that can be set to exclude headers and save as a comma-delimited file. Many prefs can be set by JSL but not all.

 

This JSL code works on Macintosh but should work on Windows as well (not tested). The code restores the original prefs after saving. However, if that's not important the script can be simplified.

 

 

dt = Current Data Table();
// Get current prefs
current_pref = Char( Arg( Parse( (Char( Get Preferences( Export settings ) )) ), 1 ) );
// Set prefs (comma delimited, no headers)
Pref( Export Settings( End Of Field( Comma ), Export Table Headers( 0 ) ) );
// Save csv file
If(
          Host is( Windows ), dt << save( "c:/mydata/test.txt" ),
          Host is( Macintosh ), dt << save( "test.csv", text )
);
//Restore oribinal prefs
Eval( Parse( "pref(" || current_pref || ")" ) );

 

mattf
Community Trekker

Re: JSL for exporting/saving JMP Data Table as a CSV file without saving the Column Headers

Worked fine on my Windows (WIN XP, JMP 9.0.2)!

Best,

-Matt

0 Kudos
ambs
Community Trekker

JSL for exporting/saving JMP Data Table as a CSV file without saving the Column Headers

Thanks MS!

I'm still using JMP 8.0... i encountered a few errors, but maybe it's because i'm using an old version...

for this line: current_pref = Char( Arg( Parse( (Char( Get Preferences( Export settings ) )) ), 1 ) );

I get this error on the log:

Name Unresolved: Get Preferences in access or evaluation of 'Get Preferences' , Get Preferences( Export settings )

In the following script, error marked by /*###*/

::dt = Current Data Table();

current_pref = Char(

Arg( Parse( Char( Get Preferences( Export settings ) /*###*/ ) ), 1 )

but since I don't need to restore the original prefs, i just deleted this part...

I also removed the checking for the OS (Mac or Windows) since i'm just using windows...

when I save a table as a txt file, the column header is removed... but when i save it as a csv file, the column header is still there...

so i guess i'll just save it as a txt file...

again, thanks a lot!

cheers!

regards,

ambs

0 Kudos
Highlighted
txnelson
Super User

Re: JSL for exporting/saving JMP Data Table as a CSV file without saving the Column Headers



 

Jim
0 Kudos