Ciao a tutti,
Ho un file CSV che viene utilizzato in JMP. Tuttavia, ho bisogno di scambiare le colonne 1 e 2 con le colonne 7 e 8. Come farlo utilizzando JSL. Sembra qualcosa del genere:
File originale
Colonne scambiate
Puoi semplicemente cambiare i nomi dell'intestazione anziché spostare i dati, oppure puoi effettivamente spostare i dati. Vedi l'esempio qui sotto
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
// Move header is easier than moving all of the data
:weight << set name("new name");
:height << set name("weight");
// One way to move data
theHeights = :weight << get values;
theWeights = :new name << get values;
:new name << set name("height");
:weight << set values(theWeights);
:height << set values(theHeights);Funziona bene. Ma solo una domanda: è possibile spostare solo i dati all'interno delle colonne e non le intestazioni? Come si fa usando JSL?
Vuoi riordinare le tue colonne o semplicemente spostare i dati all'interno delle colonne? Questo dovrebbe aiutarti a riordinare le colonne MA non funzionerà allo stesso modo con tutte le versioni di JMP a causa di come <
Names Default To Here(1);
dt = New Table("Untitled 2",
Add Rows(0),
Compress File When Saved(1),
New Column("1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("2", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("3", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("4", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("5", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("6", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("7", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("8", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("9", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);
wait(1); // demo purposes
collist = dt << Get Column Names("String");
col_order = {"7", "8", "3", "4", "5", "6", "1", "2", "9"};
dt << Move Selected Columns(col_order);