大家好,
我有一个在 JMP 中使用的 CSV 文件。但是,我需要将第 1 列和第 2 列与第 7 列和第 8 列交换。如何使用 JSL 执行此操作。它看起来像这样:
原始文件
互换列
您可以只更改标题名称而不移动数据,也可以实际移动数据。请参阅下面的示例
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);效果很好。但有一个问题,是否也可以只移动列内的数据而不移动其标题?如何使用 JSL 来实现?
您是否希望重新排列列或只是在列内移动数据?这应该可以帮助您重新排列列,但由于 <
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);