论坛您好!
我想对以“Diff”开头且值大于 .1 或缺失值 (.) 的列中的单元格进行着色,以“Diff”开头的列数将随着数据集的增长而增长。 这是我到目前为止所拥有的,但随着 # 或列的增长,从长远来看可能不会起作用。
名称默认为此处(1);
dt=当前数据表();
dt:Diff T00 << color cells("Red", dt<= .1));
dt:Diff T01 << color cells("Red", dt<= .1));
dt:Diff T02 << color cells("Red", dt<= .1));
dt:Diff T03 << color cells("Red", dt<= .1));
dt:Diff T04 << color cells("Red", dt<= .1));
dt:Diff T05 << color cells("Red", dt<= .1));
dt:Diff T06 << color cells("Red", dt<= .1));
dt:Diff T07 << color cells("Red", dt<= .1));
dt:Diff T08 << color cells("Red", dt<= .1));
dt:Diff T09 << color cells("Red", dt<= .1));
dt:Diff T10 << color cells("Red", dt<= .1));

有2个错误......
1. 我颠倒了我指定的 If() 函数的逻辑......我有“!=”,它需要是“==”。
2.颜色单元格()中的 colNames 引用必须引用特定列....我的错误也是
我还清理了你的代码......没什么大不了的,
Names Default To Here( 1 );
dt1 = Open(
Pick File(),
columns(
Column( "IM#", Character, "Nominal" ),
Column( "LREQ", Numeric, "Continuous", Format( "Best", 10 ) ),
Column( "DATE/TIME", Character, "Nominal" ),
Column( "T(x)", Character, "Nominal" ),
Column( "BOARD", Numeric, "Continuous", Format( "Best", 10 ) ),
Column( "CHANNEL", Numeric, "Continuous", Format( "Best", 10 ) ),
Column( "DATA", Numeric, "Continuous", Format( "Best", 10 ) )
),
Import Settings(
End Of Line( CRLF ),
End Of Field( Tab, Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 1 ),
Column Names Start( 1 ),
Data Starts( 2 ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
) << Set Name( "DT1" );
Data Table( "DT1" ) << Sort(
By( :BOARD, :CHANNEL, :Name( "T(x)" ) ),
Order( Ascending, Ascending, Ascending ),
replace table
) << New Column( "T00 Value",
formula( If( :Name( "T(x)" ) == "T00", :Data, :T00 Value[Row() - 1] ) )
) << New Column( "Diff",
formula( (:Data - :T00 Value) / :T00 Value ),
Format( "Percent" )
);
dt = Data Table( "DT1" ) << Split(
Split By( :Name( "T(x)" ) ),
Split( :DATA, :Name( "Diff" ) ),
Group( :IM#, :LREQ, :BOARD, :CHANNEL ),
Remaining Columns( Drop All ),
Output Table Name( "DT2" )
);
Close( Data Table( "DT1" ), No Save );
//Names Default To Here( 1 );
//dt = Current Data Table();
colNames = dt << get column names( numeric, string );
For( i = 1, i <= N Items( colNames ), i++,
If( Left( colNames[i], 4 ) == "Diff",
Column( dt, colNames[i] ) << color cells(
"Red",
dt << get rows where( As Column( dt, colNames[i] ) >= .1 )
)
)
);
嗯……这很奇怪。 王列被突出显示。 我附上了脚本和csv。 我确实收到一条错误消息,说“数据”列需要是字符类型。 但我需要它是计算的数字。
以 Diff*** > .1 ==Red 开头的列中的值
以 Diff*** 开头的列中的值 = 缺失值 ==Red

我认为这样的事情会奏效
Names Default To Here( 1 );
dt = Current Data Table();
colNames = dt << get column names( numeric, string );
For( i = 1, i <= N Items( colNames ), i++,
If( Left( colNames[i], 4 ) != "Diff",
Column( dt, colNames ) << color cells( "Red", dt << get rows where( As Column( dt, colNames ) >= .1 ) )
)
);