BookmarkSubscribe
Choose Language Hide Translation Bar
NewUser78
New Contributor

Multiple file import, control chart, image capture and then close

Hi,

 

Past user of jmp but new to scripting.  I'm looking to make my life easier and automatically create control charts from a folder containing upto 55 csv files, save an image of the control chart using the name of the csv and record the LCL, AVG and UCL from each control chart in a separate data table (an added bonus would be to automatically calculate the cpk and ppk from the data) and save in a folder of my choice, then close all data tables and control charts all from the script.

 

Currently I have the following (as I said I'm new to scipting) but using the multiple file import script and a loop I can open each data table and create control charts, I'm just not sure how to achieve the rest of my request.  Any help would be most appreciated.

 

Clear Log();


Multiple File Import(
<<Set Folder( "D:\Work\JMP script trials\" ),
<<Set Name Filter( "*.csv*;" ),
<<Set Name Enable( 0 ),
<<Set Size Filter( {4409, 4563} ),
<<Set Size Enable( 0 ),
<<Set Date Filter( {3632397829.702, 3632398887.037} ),
<<Set Date Enable( 0 ),
<<Set Add File Name Column( 0 ),
<<Set Add File Size Column( 0 ),
<<Set Add File Date Column( 0 ),
<<Set Import Mode( "CSVData" ),
<<Set Charset( "Best Guess" ),
<<Set Stack Mode( "Table Per File" ),
<<Set CSV Has Headers( 1 ),
<<Set CSV Allow Numeric( 1 ),
<<Set CSV First Header Line( 1 ),
<<Set CSV Number Of Header Lines( 1 ),
<<Set CSV First Data Line( 2 ),
<<Set CSV EOF Comma( 1 ),
<<Set CSV EOF Tab( 0 ),
<<Set CSV EOF Space( 0 ),
<<Set CSV EOF Spaces( 0 ),
<<Set CSV EOF Other( "" ),
<<Set CSV EOL CRLF( 1 ),
<<Set CSV EOL CR( 1 ),
<<Set CSV EOL LF( 1 ),
<<Set CSV EOL Semicolon( 0 ),
<<Set CSV EOL Other( "" ),
<<Set CSV Quote( "\!"" ),
<<Set CSV Escape( "" )
) << Import Data;

Names Default To Here( 1 );

dtList = {};

For( i = 1, i <= N Table(), i++,
dt = data table(i);
insert into(dtList, dt );
dtList[i] <<Control Chart Builder(
Show Capability( 1 ),
Variables( Y( :Value ) ),
Chart( Position( 1 ), Limits( Sigma( "Moving Range" ) ) ),
Chart( Position( 2 ), Limits( Sigma( "Moving Range" ) ) )


);
);

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Multiple file import, control chart, image capture and then close

Here's an example script using some JMP sample data:

 

tables = Multiple File Import(
	<<Set Folder( "$SAMPLE_DATA\Quality Control\" ),
	<<Set Name Filter( "Steam Turbine*.jmp" ),
	<<Set Name Enable( 1 ),
	<<Set Stack Mode( "Table Per File" )
) << Import Data;

for (i=1, i<=NItems(tables), i++,
	ccb = tables[i] << Control Chart Builder(
		Show Capability(1),
		Variables(Y(:Steam Temp))
	);
	(ccb<<Report) << Save Picture("$DOCUMENTS\" || (tables[i]<<Get Name) || ".png", "png");
	temp = ccb << Save Limits("In New Table");
	if (i==1,
		limits = temp;
		limits:Steam Temp << Set Name(tables[i]<<Get Name);
		,
		limits << New Column(tables[i]<<Get Name, "Numeric", "Continuous", Set Values(temp:Steam Temp << Get Values()));
		Close(temp, "NoSave");
	);
	Close(tables[i], "NoSave");
);
2 REPLIES 2

Re: Multiple file import, control chart, image capture and then close

Here's an example script using some JMP sample data:

 

tables = Multiple File Import(
	<<Set Folder( "$SAMPLE_DATA\Quality Control\" ),
	<<Set Name Filter( "Steam Turbine*.jmp" ),
	<<Set Name Enable( 1 ),
	<<Set Stack Mode( "Table Per File" )
) << Import Data;

for (i=1, i<=NItems(tables), i++,
	ccb = tables[i] << Control Chart Builder(
		Show Capability(1),
		Variables(Y(:Steam Temp))
	);
	(ccb<<Report) << Save Picture("$DOCUMENTS\" || (tables[i]<<Get Name) || ".png", "png");
	temp = ccb << Save Limits("In New Table");
	if (i==1,
		limits = temp;
		limits:Steam Temp << Set Name(tables[i]<<Get Name);
		,
		limits << New Column(tables[i]<<Get Name, "Numeric", "Continuous", Set Values(temp:Steam Temp << Get Values()));
		Close(temp, "NoSave");
	);
	Close(tables[i], "NoSave");
);
NewUser78
New Contributor

Re: Multiple file import, control chart, image capture and then close

Awesome, worked like a charm. 

 

I now need to change it as I now need to access the files through a server, pick the individual file and interrogate it that way.   The data for each measurement connected to one SPC measurement is now is one column so I have to apply filters to the column to separate the data. Any help would be most appreciated. 

0 Kudos