您好,我有一组按行包含多个产品数据的列。我需要通过创建具有产品名称后缀的新相同列来拆分这些数据,然后仅复制先前列中匹配的产品数据。我只需要帮助来复制适当的数据。我试图通过选择和复制粘贴来做到这一点,但我不知道该怎么做。感兴趣的区域从 dt << 选择位置开始。
Names Default To Here( 1 );
dt = Current Data Table();
colNames = dt << Get Column Names(String);
//Select set of columns to split
for (i = nitems(colNames), i > 0, i--,
if (!contains(colNames[i], "SPC"),
remove from(colNames, i);
);
);
//Add new columns with product name suffix and copy/paste properties
Summarize(unique_values=by(:Products));
colNames2=colNames;
for (k = nitems(unique_values), k > 0, k--,
for (i = nitems(colNames), i > 0, i--,
colNames2[i] = colNames[i] || " " || unique_values[k];
dt << New Column( colNames2[i] );
);
for( j = 1, j <= nitems(colNames), j++,
colProps = Column( dt, colNames[j] ) << Get Column Properties;
Column( dt, colNames2[j] ) << Add Column Properties( colProps );
);
<U><STRONG> dt << Select Where( :Products == unique_values[k] );
dt << selectColumns(colNames);
dt << Copy;
dt << selectColumns(colNames2);
dt << Paste;</STRONG></U>
);
你好,如果你想根据行选择复制和粘贴值,你可以编写如下代码。
我希望它有所帮助。
dt << Select Where( :Products == unique_values[k] );
r = dt << Get Selected Rows();
val = As Column( colNames[i] )[r];
For( h = 1, h <= N Row( val ), h++,
As Column( colNames2[i] )[r[h]] = val[h]
);