大家好,我想如果第一列中長度大於3的行將所有列右移一列,我想知道這是否可能?目前,我從這個開始:
dt << delete row( 1 );
rows_to_delete = dt << Get Rows Where(Length( :Prodn Supervisor )>3);
If(N Items(rows_to_delete),
dt << Delete Rows(rows_to_delete);
);

像這樣的東西應該有效
Names Default To Here( 1 );
dt = Current Data Table();
dt << delete row( 1 );
theRows = dt << Get Rows Where( Length( :Prodn Supervisor ) > 3 );
If( N Items( theRows ) > 0,
For( theCol = 1, theCol < N Col( dt ), theCol++,
For( myRow = 1, myRow <= N Items( theRows ), myRow++,
Column( theCol )[theRows[myRow]] = Column( theCol + 1 )[theRows[myRow]]
)
)
);
根據您的數據,類似的東西可能會起作用,它使用數據表下標
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(4),
New Column("A", Character, "Nominal", Set Values({"AAAA", "AAAA", "BBB", "BBB"})),
New Column("B", Character, "Nominal", Set Values({"123", "456", "AAAA", "AAAA"}), Set Display Width(45)),
New Column("C", Numeric, "Continuous", Format("Best", 12), Set Values([., ., 789, 0]))
);
rows_to_shift = dt << Get Rows Where(Length(AsColumn(1)) > 3);
col_count = N Cols(dt);
// set all columns to character to make this easier
For Each({col_name}, dt << Get Column Names("String"),
Column(dt, col_name) << Set Data Type("Character");
);
wait(1);
// Datatable subscripting
dt[rows_to_shift, 2::col_count] = dt[rows_to_shift, 1::col_count - 1];
dt[rows_to_shift, 1] = ""; // set first column values as missing目前我刪除了這些列,但我想將它們移至右側,如上所述