JSL不会设置列格式大家好,
我试图将列名称、数据类型、建模类型和格式从一张表复制到一张新表中,但是当我尝试设置列格式时,它永远不会发生,只会恢复为“最佳”。我已经为此苦苦挣扎了一段时间,并且完全困惑为什么它不起作用。下面是我的代码和结果输出,显示列格式有效,但不坚持。日志中没有报告任何错误。谁能看到我做错了什么吗?
summaryTable = New Table( "Results Summary" );
colNames = data << Get Column Names( string );
For( i = 1, i <= N Items( colNames ), i++,
colType = Column( data, colNames[i] ) << Get Data Type;
colModel = Column( data, colNames[i] ) << Get Modeling Type;
colFormat = Column( data, colNames[i] ) << Get Format;
Show( colNames[i] );
Show( colType );
Show( colModel );
<STRONG>显示(colFormat);</STRONG>
newCol = summaryTable << New Column( colNames[i] );
newCol << Data Type( colType ) << Modeling Type( colModel );
If( colType != "Character",
newCol << Format( colFormat );
<STRONG>Show( newCol << 获取格式 );</STRONG>
);
);
colNames[i] = "Label";
colType = "Character";
colModel = "Nominal";
colFormat = Format("Best");
colNames[i] = "Start_Time";
colType = "Numeric";
colModel = "Continuous";
<STRONG>colFormat = Format("m/d/yh:m:s", 23, 0); newCol << 获取格式 = Format("最佳", 10);</STRONG>
colNames[i] = "End_Time";
colType = "Numeric";
colModel = "Continuous";
<STRONG>colFormat = Format("m/d/yh:m:s", 23, 0); newCol << 获取格式 = Format("最佳", 10);</STRONG>额外的后续问题:我似乎只能使用上面的代码来设置列数据和建模类型,其中我在初始化列后设置类型。当我尝试执行下面的行时,列根本没有初始化,为什么不呢?
newCol = summaryTable << New Column( colNames[i], colType, colModel );
大规模定制回复:JSL不会设置列格式谢谢大家。我考虑复制表并删除行。该数据表由大约 2 打列组成,可能包含数百行。我认为迭代创建 2 打列可能比删除数百行更有效。 @pmroz的子集方法很聪明,我可能只是使用它。
回复:JSL 不会设置列格式假设桌子不大,并且根据马克的想法,您也可以这样做:
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Eval(dt << getScript);
dt2 << selectAllRows;
dt2 << deleteRows;回复:JSL不会设置列格式使用子集的更简单的逻辑:
data = New Table( "Test Data", Add Rows( 3 ),
New Column( "Column 1", Numeric, "Continuous", Format( "Fixed Dec", 8, 0 ),
Set Values( [1, 2, 3] )
),
New Column( "Column 2", Character, "Nominal", Set Values( {"c", "b", "a"} ) ),
New Column( "Column 3", Numeric, "Continuous", Format( "m/d/y", 10 ),
Input Format( "m/d/y" ),
Set Values( [3630873600, 3633552000, 3635971200] )
)
);
summaryTable = data << Subset( Rows( [1] ));
summarytable << delete rows([1]) << set name( "Results Summary");
回复:JSL不会设置列格式感谢您的回复。我想我没有提到“数据”是一个通过多个 SQL 查询和计算创建的已经存在的表。我想组装一个与“数据”具有相同列的汇总表,而不实际对其进行子集化。后来我以分段方式填充行。
@pmroz你的方法有效,谢谢!我仍然不明白为什么指针不起作用,但我已经不再关心这个了。
回复:JSL不会设置列格式这段代码会做到这一点:
data = New Table( "Test Data", Add Rows( 3 ),
New Column( "Column 1", Numeric, "Continuous", Format( "Fixed Dec", 8, 0 ),
Set Values( [1, 2, 3] )
),
New Column( "Column 2", Character, "Nominal", Set Values( {"c", "b", "a"} ) ),
New Column( "Column 3", Numeric, "Continuous", Format( "m/d/y", 10 ),
Input Format( "m/d/y" ),
Set Values( [3630873600, 3633552000, 3635971200] )
)
);
summaryTable = New Table( "Results Summary" );
colNames = data << Get Column Names( string );
For( i = 1, i <= N Items( colNames ), i++,
colType = Column( data, colNames[i] ) << Get Data Type;
colModel = Column( data, colNames[i] ) << Get Modeling Type;
colFormat = char(Column( data, colNames[i] ) << Get Format);
Show( colNames[i] );
Show( colType );
Show( colModel );
Show( colFormat );
newCol = summaryTable << New Column( colNames[i] );
newCol << Data Type( colType ) << Modeling Type( colModel );
if (coltype != "Character",
new_expr = "newcol << " || colformat;
eval(parse(new_expr));
);
);回复:JSL 不会设置列格式保存原始数据表的副本并打开副本继续继续会更容易吗?
回复:JSL不会设置列格式你好,
首先,我认为“数据”没有被定义。
Clear Globals();
summaryTable = New Table( "Results Summary" );
colNames = data << Get Column Names( string );
结果是
Data Table( "Results Summary" )
//:*/
colNames = data << Get Column Names( string );
/*:
Send Expects Scriptable Object in access or evaluation of 'Send' , data << /*###*/Get Column Names( string ) /*###*/
In the following script, error marked by /*###*/
colNames = data << /*###*/Get Column Names( string ) /*###*/
{}