我正在寻找一种使用宏从多个csv文件中删除某些列的方法。
我发现了前面回答的问题:How can you delete the first and fifth columns from 100 CSV files with EmEditor?
但这只适用于列号。
我试着创建了这样一个宏:
document.DeleteColumn( Example1 ); // Delete Column With Header Example1
document.DeleteColumn( Example2 ); // Delete Column With Header Example2```
But I then get an error saying the example string is unspecified.
Is there a way to do this? Thank you in advance.发布于 2022-07-29 16:46:18
DeleteColumn()的参数必须是整数值。下面是一个JavaScript宏,用于删除标题名称指定的两列。
asHeader = ["Example1", "Example2"];
function DeleteColumnByString( sHeader )
{
document.selection.StartOfDocument();
nMaxCol = document.GetColumns();
document.selection.SetActivePoint( eePosCellLogical, nMaxCol, 1, true );
if( document.selection.Find( sHeader,eeFindNext | eeFindReplaceCase | eeFindReplaceSelOnly,0) ) {
iCol = document.selection.GetActivePointX( eePosCellLogical );
document.selection.Collapse();
document.DeleteColumn( iCol );
}
}
for( i = 0; i < asHeader.length; ++i ) {
DeleteColumnByString( asHeader[i] );
}要运行宏,请将下面的代码保存为例如RemoveColumn.jsee,然后在宏菜单中从Select.中选择此文件。最后,在宏菜单中选择Run RemoveColumn.jsee。
https://stackoverflow.com/questions/73166798
复制相似问题