BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
AnthonyS

Community Trekker

Joined:

Jan 15, 2018

Script extraction

Good morning

 

I need a script for extract the .txt datas in a forder and make the average with the datas in the other folder. But the datas must stay in columns. I can tell u a test folder.

Can you help me ? (Sorry for my English)  

 

Best regards,  

 

AnthonyS

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Re: Script extraction

The data files in the folder structure that you attached can be read in very easily.  The only complexity was in finding the row number the data starts on(61), and the delimiter used to separate the different data fields.(Tab). 

To read in the data, go to

     File==>Open

Then navigate to the folder where the data are and click on the file you want to open.  Only click once on it, and it will display some additional choices

average issue 2.PNG

As seen above select "Data with Preview"

Then click on Open.

You will then be presented with the following screen

average issue.PNG

Change the screen to match the above settings, then click on the "Next" button.

On the next screen that is displayed, you can preview the data that will be input.  Click on the "Import" button when you are ready, and the data table will be opened and displayed.

Repeat the same process for to import the second data table.

To accomplish your request for the displaying of the averages, I suggest you use

     Cols==>Column Viewer

 

You appear to be very new to JMP.  I strongly suggest that you read the documentation provided with JMP

     Help==>Books==>Discovering JMP, Using JMP, Basic Analysis

Jim
5 REPLIES 5
txnelson

Super User

Joined:

Jun 22, 2012

Re: Script extraction

If you could show what the input folder and a sample of the files in the folder would be very helpful.

Jim
AnthonyS

Community Trekker

Joined:

Jan 15, 2018

Re: Script extraction

Here's the forlder ans the files.

 

i need make a average under the preliminary and the repeatability data. And compare the post-stress withe this average but in columns.

 

thank you very much,

 

AnthonyS

 

 

 

Highlighted
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Re: Script extraction

The data files in the folder structure that you attached can be read in very easily.  The only complexity was in finding the row number the data starts on(61), and the delimiter used to separate the different data fields.(Tab). 

To read in the data, go to

     File==>Open

Then navigate to the folder where the data are and click on the file you want to open.  Only click once on it, and it will display some additional choices

average issue 2.PNG

As seen above select "Data with Preview"

Then click on Open.

You will then be presented with the following screen

average issue.PNG

Change the screen to match the above settings, then click on the "Next" button.

On the next screen that is displayed, you can preview the data that will be input.  Click on the "Import" button when you are ready, and the data table will be opened and displayed.

Repeat the same process for to import the second data table.

To accomplish your request for the displaying of the averages, I suggest you use

     Cols==>Column Viewer

 

You appear to be very new to JMP.  I strongly suggest that you read the documentation provided with JMP

     Help==>Books==>Discovering JMP, Using JMP, Basic Analysis

Jim
AnthonyS

Community Trekker

Joined:

Jan 15, 2018

Re: Script extraction

Sorry i haven't explainned myself well, 

 

i need a script for extract all files in the sub folder and concatain this in the jmp data table like the script an attachment "Script_Base".

And after i need create new culumns "AVERAGE_VBIAS" , calculate the average under the ''MEAN_VBIAS_MEAS'' preliminary and repeatability:

 

example:

avarage under preliminary and repeatability  ''MEAN_VBIAS_MEAS''  by "BRIDGE_NUMBER" by  "SAMPLE_ID"

 

And also for the columns "MEAN_VOUT_MEAS" and "MEAN_BRIDGE_RATIO".

 

Best regards,

 

Anthony 

 

 

 

 

 

 

 

 

txnelson

Super User

Joined:

Jun 22, 2012

Re: Script extraction

Here is a good beginning to what you want.  If it isn't quite what you want, it should give you sufficient examples that should allow you to make the modifications needed.

Names Default To Here( 1 );
Clear Symbols();

// Add in the all of the folders that need to have data tables read in from

prefilepathList = {
	"C:\Users\txjim\Documents\average issue\BEAVD\REPEATABILITY\",
	"C:\Users\txjim\Documents\average issue\BEAVD\PRELIMINARY\"
};

cctable = New Table( "Combined data table " );//make an empty table
cctable << New Column( "Source", Character, Nominal );
	
For( path = 1, path <= N Items( prefilepathList ), path++,
	filepath = prefilepathList[path];

	prefilelist = Files In Directory( filepath );
	
	n2 = N Items( prefilelist );
	filelist = {};
	
	//filter out any non-txt or csv files
	For( i2 = 1, n2 >= i2, i2++,
		file = (prefilelist[i2]);
		If(
			Item( 2, prefilelist[i2], "." ) == "txt" | Item( 2, prefilelist[i2], "." ) == "csv" |
			Item( 2, prefilelist[i2], "." ) == "dat",
			Insert Into( filelist, file ),
			Show( file )
		);
	);

	nf = N Items( filelist ); //number of items in the working list
	
	For( iii = 1, iii <= nf, iii++, //this starts the first loop
		filenow = (filelist[iii]);
		fileopen = (filepath || filenow);

		dt = Open(
			fileopen,
			Import Settings(
				End Of Line( CRLF, CR, LF ),
				End Of Field( Tab, Other( ";" ), CSV( 0 ) ), //use ";" as a delimiter too
				Strip Quotes( 1 ),
				Use Apostrophe as Quotation Mark( 0 ),
				Scan Whole File( 1 ),
				Treat empty columns as numeric( 0 ),
				CompressNumericColumns( 0 ),
				CompressCharacterColumns( 0 ),
				CompressAllowListCheck( 0 ),
				Labels( 1 ),
				Column Names Start( 61 ), //starting on second row
				Data Starts( 62 ), //data starts on 3rd row
				Lines To Read( "All" ),
				Year Rule( "20xx" )
			),
			invisible
		);//Import settings used in the open argument

		New Column( "Source", Character, Nominal );
		:Source << set each value( filenow );

		dt << Run Formulas();
		
		//add the current table to the bottom of the combined data table
		cctable << Concatenate( Data Table( dt ), Append to first table );

		Close( dt, NoSave );//after concatenating the table, close it and move on
	);//end of the first for loop
);

// Calculate the output
Tabulate(
	Show Control Panel( 0 ),
	Add Table(
		Column Table( Analysis Columns( :MEAN_VBIAS_MEAS ), Statistics( Mean ) ),
		Column Table( Analysis Columns( :MEAN_VOUT_MEAS ), Statistics( Mean ) ),
		Column Table( Analysis Columns( :MEAN_BRIDGE_RATIO ), Statistics( Mean ) ),
		Row Table( Grouping Columns( :BRIDGE_NUMBER, :SAMPLE_ID ) )
	)
)
Jim