cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
adjo9835
Level II

JSL- How do I get rid of quotation marks when saving to .mdf file

The code shown below saves the data shown below into a .mdf file, however, I cant figure out how to keep JMP from writing the quotation marks shown at the beginning of the saved data.  How do I get rid of these quotation marks?

 

DataCV=open("C:\Desktop\JMP\sample_data.csv"); 
Summarize( DataCV, processArray = By( :process ) );

For( m = 1, 
m <= Length( processArray ), 
m++,		// Generates and saves all Cdg splines
	Eval(
		Substitute(
				Expr(
					biv = Bivariate(
						Y( :c_mm_deembed_pf ),
						X( :v_dut_volt ),
						Where( :c_type == "Cdg" & :process == __process__ ),
						Fit Spline( 0.1, standardized, {save predicteds} )	
					)
				),
			Expr( __process__ ), processArray[m]
		)
	)
);

(Data Table( DataCV ) << Tabulate(	// Create new table
       Add Table(
              Column Table( Analysis Columns( :Spline Predictor for c_mm_deembed_pf Where ) ),
              Row Table( Grouping Columns(:serial_num, :process, :c_type, :v_dut_volt ) )
       )
)) << Make Into Data Table;

currentDataTable()<<AddRows(1);	// Add an empty last row so while loop knows when its at the end

q = 0;
proc = "new";
i = 1;
while(q == 0,			// Delete redundant splines (:process x :c_type combinations)
	if (proc != :process[i], 
		proc = :process[i]; sn = :serial_num[i]; i+=1
	);
	if (proc == :process[i] & sn == :serial_num[i],					
		i+=1	
	);				
	if (proc == :process[i] & sn != :serial_num[i],	
		CurrentDataTable()<<DeleteRows(i) 
	);
	if (:process[i] == "",
		q = 1;
	);
);

currentDataTable() << Delete Rows(i);	// Delete empty last row
currentDataTable() << new column("Index", character);

cap = "new";
for (k = 1, k<=NRows(currentDataTable()), k++,	// Add VARs for ADS indexing
	if (cap != :c_type[k], 
		currentDataTable() << Add Rows(1, k-1); j=1; cap = :c_type[k+1]; proc = :process[k+1]
	);
	if (j==1,
		For Each Row(:Index = if(:c_type=="", 	// This is where the quotation marks originate from
					"\!NVAR CURVE(1) = " || char(cap) || "\!NVAR TECH(1) = " || char(proc) || "\!NBEGIN\!N% ind(1)	dep(1)", 
					:Index));
		For Each Row(:c_type = if(:c_type=="", 
					char(cap), 
					:c_type)); j=0
	);
);


currentDataTable() << delete columns("c_type", "serial_num", "process");	// Delete all rows except for ind(1) and dep(1)

xptPref = Get Preferences( Export Settings );	// .MDF format
Preferences(
	ExportSettings(
		End Of Line( CRLF ),
		End Of Field( Tab ),
		Export Table Headers( 0 )
	)
);

currentDataTable () << Save As( "C:\Desktop\JMP\GeneratedFiles\RoughDraft2Output.mdf", "text" );	// Save as .MDF, however, i dont want any quotes

 

		"
VAR CURVE(1) = Cdg
VAR TECH(1) = G50V3-3
BEGIN
% ind(1)	dep(1)"
0.1392	3.1931865994	
1.139	2.7623010959	
2.1344	2.3391306476	
3.1346	1.9319516519	
4.0714	1.5817641476	
5.0892	1.2466683948	
6.0128	0.9880976277	
6.971	0.7661291093	
7.8366	0.6040645312	
8.7254	0.4720246289	
9.5982	0.3719428625	
10.379	0.303489106	
11.2286	0.2476917169	
12.0762	0.2076956614	
12.8542	0.1818554683	
13.715	0.1626401602	
14.5604	0.1510540199	
15.486	0.1444224576	
16.365	0.1422448881	
17.274	0.1427599758	
18.1818	0.1449372904	
19.0986	0.1479270102	

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JSL- How do I get rid of quotation marks when saving to .mdf file

I think you might have a better chance of getting what you want, if you use the below JSL, replacing everything from line 52

cap = "new";

to the bottom, with:

save text file("C:\Desktop\JMP\GeneratedFiles\RoughDraft2Output.mdf",
	"\!NVAR CURVE(1) = " || char(:c_type[1]) || "\!NVAR TECH(1) = " || char(proc) || "\!NBEGIN\!N% ind(1)	dep(1)",
	mode( "replace" )
);

for (k = 1, k<=NRows(currentDataTable()), k++,
	If(:c_type[i] != lag(c_type[i]) & k > 1,
		save text file("C:\Desktop\JMP\GeneratedFiles\RoughDraft2Output.mdf",
			"\!NVAR CURVE(1) = " || char(:c_type[1]) || "\!NVAR TECH(1) = " || char(proc) || "\!NBEGIN\!N% ind(1)	dep(1)",
			mode( "append" )
		);
	);
	save text file("C:\Desktop\JMP\GeneratedFiles\RoughDraft2Output.mdf",
		char(:v_dut_volt) "\!t" char(:Name("Sum(Spline Predictor for c_mm_deembed_pf Where)")) || "\!n",
		mode( "append" )
	);
);

I have used the Save Text File() function many times when I need to create a text file of a specific format.  It will strip out the quotations.

Jim

View solution in original post

7 REPLIES 7

Re: JSL- How do I get rid of quotation marks when saving to .mdf file

What version of JMP are you using?  I don't replicate the behavior using JMP 14 with the following simple example:

Preferences(
	ExportSettings(
		End Of Line( CRLF ),
		End Of Field( Tab ),
		Export Table Headers( 0 )
	)
);
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt << Save As( "$TEMP\Big Class_text.mdf", "text" );

Notice there is no double-quote shown at the top of the file in a common text editor:

Capture.JPG

Wendy
adjo9835
Level II

Re: JSL- How do I get rid of quotation marks when saving to .mdf file

Im using JMP 13.0.0.  However, my script is quite a bit different from the script you are running. A seciton of my code inserts information into specific rows, as shown below.  This is where the unwanted quotes are originating from. 

cap = "new";
For( k = 1, k <= N Rows( Current Data Table() ), k++, 	// Add VARs for ADS indexing (This is where unwanted quotation marks originate from)
	If( cap != :c_type[k],
		Current Data Table() << Add Rows( 1, k - 1 );
		cap = :c_type[k + 1];
		proc = :process[k + 1];
		For Each Row(
			If( :c_type == "",
				:c_type = "Blank";
				:Index = "\!NVAR CURVE(1) = " || Char( cap ) || "\!NVAR PROCESS(1) = " ||
				Char( proc ) || "\!NVAR RETICLE(1) = " || Char( ret ) ||
				"\!NBEGIN\!N% ind(1)	dep(1)";
			)
		);
	)
);

Re: JSL- How do I get rid of quotation marks when saving to .mdf file

It's because of the returns in the text string.

The file uses returns to signal the end of a line 

End Of Line( CRLF )

If this piece isn't quoted when it's saved out to a text file:


VAR CURVE(1) = F
VAR TECH(1) = 12
BEGIN
% ind(1)	dep(1)

Then each one of those lines would count as a row when you later parse the file to add to a database or open with Excel.

For example, if you edit your file so that you have two copies - one with the quotes and one without, you get two very different results when opening in Excel.

With quotes, it's seen as one string that gets put into the correct cell.

Without the quotes, Each of the five lines (including the blank one) is seen as its own row, and each line goes into the first cell in a row before you get to the rest of the data.

 

HTH,

Melanie

adjo9835
Level II

Re: JSL- How do I get rid of quotation marks when saving to .mdf file

I don't follow.  When I take the quotes out of 

"\!NVAR CURVE(1) = " || char(cap) || "\!NVAR TECH(1) = " || char(proc) || "\!NBEGIN\!N% ind(1) dep(1)", 

to arrive at 

\!NVAR CURVE(1) = || char(cap) || \!NVAR TECH(1) =  || char(proc) || \!NBEGIN\!N% ind(1) dep(1), 

I get a compilation error.  How did you get each line to go into its own cell, without any quotation marks in the output?

Re: JSL- How do I get rid of quotation marks when saving to .mdf file

I'm sorry - I wasn't clear. I opened the .mdf file in a text editor, removed the quotation marks, and saved under a different file. This exercise just shows why you have to have the quotation marks there.

If you need to remove them completely, then you'll have to remove the returns from that piece of text. It looks like a code snippet, so I don't know if that will work for you, but this structure will not work without either the returns or the quotes.

adjo9835
Level II

Re: JSL- How do I get rid of quotation marks when saving to .mdf file

 

When you say "remove the returns from that piece of text," do you mean taking the lines of code shown below:

For Each Row(:Index = if(:c_type=="", 
			"\!NVAR CURVE(1) = " || char(cap) || "\!NVAR TECH(1) = " || char(proc) || "\!NBEGIN\!N% ind(1)	dep(1)", 
			:Index));

and turning them into into this:

For Each Row(:Index = if(:c_type=="", 
"VAR CURVE(1) = " || char(cap) || "VAR TECH(1) = " || char(proc) || "BEGIN% ind(1) dep(1)",
:Index));

?

Doing that returns the image shown below, which still includes the quotation marks.image.png

How do I get my output to go from the format shown below:

image.png

To this format shown below?

image.png

txnelson
Super User

Re: JSL- How do I get rid of quotation marks when saving to .mdf file

I think you might have a better chance of getting what you want, if you use the below JSL, replacing everything from line 52

cap = "new";

to the bottom, with:

save text file("C:\Desktop\JMP\GeneratedFiles\RoughDraft2Output.mdf",
	"\!NVAR CURVE(1) = " || char(:c_type[1]) || "\!NVAR TECH(1) = " || char(proc) || "\!NBEGIN\!N% ind(1)	dep(1)",
	mode( "replace" )
);

for (k = 1, k<=NRows(currentDataTable()), k++,
	If(:c_type[i] != lag(c_type[i]) & k > 1,
		save text file("C:\Desktop\JMP\GeneratedFiles\RoughDraft2Output.mdf",
			"\!NVAR CURVE(1) = " || char(:c_type[1]) || "\!NVAR TECH(1) = " || char(proc) || "\!NBEGIN\!N% ind(1)	dep(1)",
			mode( "append" )
		);
	);
	save text file("C:\Desktop\JMP\GeneratedFiles\RoughDraft2Output.mdf",
		char(:v_dut_volt) "\!t" char(:Name("Sum(Spline Predictor for c_mm_deembed_pf Where)")) || "\!n",
		mode( "append" )
	);
);

I have used the Save Text File() function many times when I need to create a text file of a specific format.  It will strip out the quotations.

Jim