cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
david_sam
Level II

rename column names in a jmp file as per values in rows in a separate .csv file

Hello, 

I am newbie to JSL, so appreciate help.
I have three files.

file #1: It is the Reference file, [as ref.csv] holding 3 cols as below. 

 

Category, width, label
--------------------------------
A,0,L1.abc
A,1,L2.xt
A,2,L8.dr
A,3,L20.ws
A,4,L72.oz
B,0,L11.qq
....
B,6,L61.er

 

file #2: data file#1 in JMP, holding Category, Data and many other cols.
file #3: data file #2 in JMP, holding Category, Data and many other cols.
difference between the two data files [File #2 and file #3] is the category type and width of value in data col.

Data file #1:

Category|data|many cols.....
----------------------------------------
A 123.23 ....
A 321.45 .... 
.....
many rows

 

the width of values in the column "data" [excluding the dots] is matching to the # of rows in file #1 for a given category
example:
width of 123.23 in row 1 in data file#1 is 5.
the # of rows in reference file for category A would be 5. this need not be tested per say. this is how the tables are coming in [ie when pulled from the source]

In the future, in the reference file , say for category A , the # of rows increase to 6 or more, the width of the value held in the data column in file data file #1 would also increase when information is pulled from database.

Data file #2:

Category|data|many cols.....

----------------------------------------
B 1236.23 ....
B 3213.45 .... 
.....
many rows


Goal 1:create new cols dependent on the width of value held in the "data" col in the datafile #1 [and other data files]
I am done with goal # 1 !


ex:
updated data file#1 would look like this:
Category|data|c1|c2|c3|c4|c5|many cols.....
----------------------------------------
A 123.23 1 2 3 2 3 ....
A 321.45 3 2 1 4 5 .... 
.....


goal 2: rename the new cols in data file #1 [ie c1 to c5] to L1... to L72... as defined in the column "label" in the reference file. no change in the cells values, just update the selected col names.


expected output after goal 2 is done:
Update the data file #1 to look like this:
Category|data|L1.abc|L2.xt|L8.dr|L20.ws|L72.oz|many cols.....
----------------------------------------
A 123.23 1 2 3 2 3 ....
A 321.45 3 2 1 4 5 .... 
.....


I need help with goal #2.

For goal #2 I opened the reference file but not sure to move forward.

 

Thanks
David

10 REPLIES 10
txnelson
Super User

Re: rename column names in a jmp file as per values in rows in a separate .csv file

OK.....this is a bit picky.....but what is in the dataTablesList are not a list of data table names but data table() functions, which point to data tables.
{"Table1","Table2"} // A list of data table names
{ data table( "Table1" ), data table( "Table2" ) } // a list of pointers to data tables
Jim

Recommended Articles