Hello,
In JSL, I want to use a specific cell value to create a column. how can I do it?
From this:
| ID | |
| 1122 | |
| Name | Age |
| Johan | 23 |
| David | 34 |
| Jack | 27 |
to This:
| ID | Name | Age |
| 1122 | Johan | 23 |
| 1122 | David | 34 |
| 1122 | Jack | 27 |
For this specific case this should work:
Names Default To Here(1);
dt = New Table("Untitled 5",
Add Rows(6),
Compress File When Saved(1),
New Column("Column 1",
Character,
"Nominal",
Set Values({"ID", "1122", "Name", "Johan", "David", "Jack"})
),
New Column("Column 2",
Character(16),
"Nominal",
Set Values({"", "", "Age", "23", "34", "27"})
)
);
wait(1);
//get column name
columnNameCell = dt[1,1];
//get cell value
valueCell = dt[2,1];
//Rename columns
Column(dt,1) << Set Name(dt[3,1]);
Column(dt,2) << Set Name(dt[3,2]);
//Remove extra rows
dt << Delete Rows([1,2,3]);
//create new column
dt << New Column(columnNameCell, Character, Nominal, << Set Each Value(valueCell));
//Move ID column
dt << Move Selected Columns(:ID, To First);For modifications like this I think Data Table Subscripting is very helpful
nice! I don't think I understood the question until I ran your answer a line at a time.