Subscribe Bookmark RSS Feed

How to Export a data table to a CSV where all data values are in double quotes

ckerr

Community Trekker

Joined:

Sep 3, 2014

Is there a way to change the export settings so that all values in the resulting CSV file are enclosed with double quotes?

Current output example: 1000,AA,Room,8,Center,...

Desired output example: "1000","AA","Room","8","Center",...

 

I pulled this script from a related post, but can't seem to find the correct settings to make it work:

 

dt = Current Data Table();
// Get current prefs
current_pref = Char( Arg( Parse( (Char( Get Preferences( Export settings ) )) ), 1 ) );
show(current_pref);
// Set prefs (comma delimited, quotes, keep headers)
Pref( Export Settings( End Of Field( double quote, CSV(0) ), Export Table Headers( 1 ) ) ); //what settings here would give the double quotes?
// Save csv file
dt << save( "$Desktop\test.csv" );
//Restore original prefs
Eval( Parse( "pref(" || current_pref || ")" ) );

 

Thanks in advance for any suggestions.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

The Export Preferences in JMP are quite limited.  I am not aware of a Double Quote option.  However, a work around is to add the quotes into the character columns before the export.  That should give you what you want.  Below is a simple script that you can expand on to set the preceeding and following quotes.

dt=current data table();
for each row(
	:region = "\!""||:region||"\!"";
)
Jim
ckerr

Community Trekker

Joined:

Sep 3, 2014

Solution
The very thing for it!
In testing it out I'm finding that any numeric & continuous columns needed to be assigned to character & nominal FIRST, but then it works just fine.
2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

The Export Preferences in JMP are quite limited.  I am not aware of a Double Quote option.  However, a work around is to add the quotes into the character columns before the export.  That should give you what you want.  Below is a simple script that you can expand on to set the preceeding and following quotes.

dt=current data table();
for each row(
	:region = "\!""||:region||"\!"";
)
Jim
ckerr

Community Trekker

Joined:

Sep 3, 2014

Solution
The very thing for it!
In testing it out I'm finding that any numeric & continuous columns needed to be assigned to character & nominal FIRST, but then it works just fine.