Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
ArmagVinc
Level II

Script import csv data (conversion of stdf)

Hi all,

 

I work with STDF files containing probe test informations, we already convert these files into csv file, I attached an example.

I would like to import easisly these files into JMP with a script.

The csv file to import to jmp sounds like:

 

info1, data1
info2,data2
info3, data3
info4,data4
info4,data5
etc
etc
infoN,dataN
 
 
test1_name,test2_name,test3_name,......
test1_num,test2_num,test3_num,…..
patt1,patt2,patt3,….
unit1,unit2,unit3
lowlimit1,lowlimit2,lowlimit3,….
highlimit1,highlimi2,highlimit3,…
Data,data,data,..
Data,data,data,..
 
…....

 

The script should generate a table like:

 

 

 

The script should generate a table in which colum names are: test1_name,test2_name etc, and data directely, so the lines (patt, unit, lowlimit, highlimit are not taken into account). Nice to add column names info1, info2, info3 all filled with same value (data1, data2, data3).

 

Thanks a lot for your help, suggestions. My Team is buying several JMP lecenses but we should need a script to import easily csv files (generated fro; stdf source files).

 

Thanks,

Vinc

3 REPLIES 3
Highlighted

Re: Script import csv data (conversion of stdf)

This file does not seem to be a simple flat file using the CSV convention. Such a file would have a line with column names separated by a column (variables or fields) followed by separate lines with data in the same order for each observation or record (row). Your file has values separated by a comma but the header information and the data appear to be spread across many rows.

 

It is likely that a script would be required read the entire file as a character string, parse the string, and store the individual results in a new data table.

Learn it once, use it forever!
Highlighted
ArmagVinc
Level II

Re: Script import csv data (conversion of stdf)

thanks a lot for this feedback, since I am quite new with JSL scripts programmimg I have not idea how to implement this task through script code.
Any kind of example to manage open files and organize data into table should be very helpful for me, I could take inspiration from them !!
Highlighted

Re: Script import csv data (conversion of stdf)

This example illustrates one way you might convert the SDTF file into a JMP data table.

 

Names Default to Here( 1 );

// open data file
content = Load Text File( "path/filename.txt" );

// break data into separate lines collected as a list
content = Words( content, "\!n" );

// move past first block of information
item = 1;
While( Length( content[item] ) != 0, item++ );

// obtain test names as a list
item += 2;
name = Words( content[item], "," );

// make data table ready
dt = New Table( "STDF Data" );

For( item += 6; col = 1, col <= N Items( name ), item++; col++,
	// obtain test data for this column
	line = Words( content[item], "," );
	data = List();
	For( i = 1, i <= N Items( line ), i++,
		Insert Into( data, Eval( Num( line[i] ) ) );
	);
	dt << New Column( name[col],
		Values( data )
	);
);

 

I based it on my understanding of the structure of the STDF file and the desired data table.

Learn it once, use it forever!
Article Labels

    There are no labels assigned to this post.