例如我有一张表:

1. 所有列名都包含“CHA/”,我如何才能快速将其删除并保留为“温度”“压力”和“流量”?在实际情况下,我有数百个包含“CHA/”的列。
2. 如何将第一行设为列名?
3. 有没有办法从表格中的所有单元格中删除“CHA/”?
谢谢你!
- @jthi提供了一个很好的交互式解决方案,但是您可能需要考虑使用一个简单的脚本来更改以 CHA/ 开头的列名
Names Default To Here( 1 );
dt = Current Data Table();
nameList = dt << get column names( string );
<BR />
For Each( {col}, nameList,
If(
Starts With(
col,
"CHA/",
Column( dt, col ) << set name( Substr( col, 5 ) )
)
)
);
2.
1.如果您的数据是从csv或txt文件输入的,您可以使用输入向导指定使用第1行作为列标题。
2.或者您可以使用一个简单的脚本来完成工作。
Names Default To Here( 1 );
dt = Current Data Table();
nameList = dt << get column names( string );
For Each( {col}, nameList,
column( dt, col) << set name( col[1] )
);
dt << delete rows(1);
3. 在列中搜索值“CHA”
1. 如果值位于需要为数字的列中,则只需将列更改为数字即可从列中的单元格中删除 CHA。
2. 或者这个简单的脚本也可以
Names Default To Here( 1 );
dt = Current Data Table();
nameList = dt << get column names( string );
For Each( {col}, nameList,
Try( Column( dt, col )[dt << get rows where( col == "CHA" )] = "" )
);谢谢你!
我将尝试您展示的脚本,它更加灵活,可以满足更多定制化要求。