cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
ckerr
Level III

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

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

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

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

View solution in original post

ckerr
Level III

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

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.

View solution in original post

3 REPLIES 3
txnelson
Super User

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

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
Level III

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

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.
Craige_Hales
Super User

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

Anyone landing here: preferences were added for this a while back; JMP 15, 14 (and perhaps 13?) have this:

Capture.PNG

All these preferences can do is force JMP to add the extra quotation marks even if not strictly needed. The preferences can't make JMP remove the quotation marks that are needed to prevent ambiguity; fields containing commas, quotation marks, and newlines need quotation marks.

Craige