大家好,
我有一個在 JMP 中使用的 CSV 檔案。但是,我需要將第 1 列和第 2 列與第 7 列和第 8 列互換。它看起來像這樣:
原始文件
互換列
您可以只更改標頭名稱而不移動數據,也可以實際移動數據。請參閱下面的範例
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);