cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar

I was able to invoke csv files and concatenate them to a JMP table. I added some editing (modify column names, add column names, etc). I want to invoke another user defined csv file as another jmp table and extract information from that to add to the first concatenated JMP table

Please see my script so far. At the end of the script, I want to open another csv file into a jmp table and extract columns into the originally created jmp table from the first invocation.

Names Default To Here(1);
//dt = Open( "C:\Users\VISHAL.SANGHAI\OneDrive - MiniCircuits\Documents\Mini Circuits Work Folder\US-AMP\US-AMP-2\Pkg data V1 old epi June 2024 testing\Power with new epi boards - Jul 2024\USAMP2_newepi_U2_VG_np465_VD_15_ID_500mA_VC_9_P5dB_biasteeoutsideTC_postdecap.csv" );


//concatenate files
// Setup an empty table to start to concatenate other tables to
dtbase = New Table("Base Table");
// Have the user select the starting folder
dirpath = Pick Directory("Pick the Top Level Directory");
// Get all of the files in all of the folders that are under the picked folder
TheFileList = Files In Directory(dirpath, "recursive");

               
// Go through all of the files and read in append those that meet your
// requirement.  You will need to amend the IF statement to meet your criteria
For(i = 1, i <= N Items(TheFileList), i++,
	If(Uppercase(Word(-1, TheFileList[i], ".")) == "CSV" & Is File(dirpath || TheFileList[i]) == 1,
		dt = Open(dirpath || TheFileList[i]);                                                               //to add filename as separate column in datatable
             		dtname = dt << get name();                                                                            //to add filename as separate column in datatable
             		dtname_list = Repeat({dtname}, N Row(dt));                                                        //to add filename as separate column in datatable
             		dt << New Column("Filename", character, set values(dtname_list));                                 //to add filename as separate column in datatable
             		dtbase = dtbase << concatenate(dt, append to first table(1));
              
             		Close(dt, nosave);
	)
);


// Add Global info as table variables
// Scan the data table based on column and assign the right row
theRow = 1;
While(Column(dtbase, 1)[theRow] != "Freq(Hz)",
	If(Column(dtbase, 2)[theRow] != "",
		dtbase << new table variable(Column(dtbase, 1)[theRow], Column(dtbase, 2)[theRow])
	);
	theRow++;
);

// Get rid of unwanted rows (removal of blanks)
dtbase << select where(As Column(dtbase, 5) == "" & As Column(dtbase, 6) == "");
dtbase << delete rows;

// Rename columns
theRow = (dtbase << get rows where(As Column(dtbase, 1) == "Freq(Hz)"))[1];
For(i = 1, i <= N Cols(dtbase), i++,
	If(
		Column(dtbase, i)[theRow] ==
		"USAMP2_newepi_U1_VG_np467_VD_15_ID_500mA_VC_9_P5dB_biasteeoutsideTC_postdecap", "Filename",
		Column(dtbase, i)[theRow] != "Filename",
			Column(dtbase, i) << set name(Column(dtbase, i)[theRow])
	)
);
dtbase << delete rows(theRow);

//Convert columns to numeric
Local({old dt = Current Data Table()},
	Current Data Table(dtbase("base_table"));
	For Each({col, index},
		{:"Freq(Hz)"n, :"S21 Log Mag(dB)"n, :"S11 Log Mag(dB)"n, :"S12 Log Mag(dB)"n,
		:"S22 Log Mag(dB)"n, :"CompIn21 Log Mag(dBm)"n, :"CompOut21 Log Mag(dBm)"n,
		:"DeltaGain21 Log Mag(dB)"n, :"CompDMM VC Lin Mag(A)"n, :"CompDMM VD Lin Mag(A)"n},
		col << Data Type(Numeric) << Set Modeling Type("Continuous") << Set Field Width(12)
	);
	Current Data Table(old dt);
);


// Add New column: Freq(GHz)
Data Table("Base Table") << New Column("Freq(GHz)",
	Numeric,
	"Continuous",
	Format("Best", 12),
	Formula(:"Freq(Hz)"n / 1000000000)
) << Move Selected Columns({:"Freq(GHz)"n}, after(:"Freq(Hz)"n));
Data Table("Base Table") << Text to Columns(columns(:Filename), Delimiters("_"));

//Rename columns
:Filename1 << Set Name(" Product ID");
:Filename 2 << Set Name(" Variant*");
:Filename 3 << Set Name(" SN#");
:Filename 4 << Set Name(" VG ");
:Filename 5 << Set Name(" VG value ");
:Filename 6 << Set Name(" VD ");
:Filename 7 << Set Name(" VD value ");
:Filename 8 << Set Name(" ID ");
:Filename 9 << Set Name(" ID value ");
:Filename 10 << Set Name(" VC ");
:Filename 11 << Set Name(" VC value ");
:Filename 12 << Set Name(" Parameter ");


//Save JMP table
dtbase << save("")


//thru_line_file = Pick File ("Pick a Data File");

//After this point, I need to allow user to pick a file. once he picks it, I would like to extract a column from that file by matching one column (common to both files) and get that column into the base table I created before.
;
Edit 2024-09-13 jthi: Added JSL formatting
 
Thanks,
Vishal
1 REPLY 1
jthi
Super User

Re: I was able to invoke csv files and concatenate them to a JMP table. I added some editing (modify column names, add column names, etc). I want to invoke another user defined csv file as another jmp table and extract information from that to add to the first concatenated JMP table

You can use Pick File() to let user select a file and after that you might be able to use Update to add the new information to your table. Do the update first interactively in JMP and then get the script created by JMP

-Jarmo