JSLは列フォーマットを設定しませんこんにちは、みんな、
列名、データ型、モデリングタイプ、および形式を1つのテーブルから新しいテーブルにコピーしようとしていますが、列形式を設定しようとすると、「ベスト」に戻ることはありません。 私はしばらくこれに頭をぶつけてきましたが、なぜそれが機能しないのか完全に困惑しています。 以下は私のコードであり、列の形式を示す結果の出力は有効ですが、固執しません。 ログにエラーは報告されていません。 誰かが私が間違っていることを見ることができますか?
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> Show( colFormat );</STRONG>
newCol = summaryTable << New Column( colNames[i] );
newCol << Data Type( colType ) << Modeling Type( colModel );
If( colType != "Character",
newCol << Format( colFormat );
<STRONG> Show( newCol << Get Format );</STRONG>
);
);
colNames[i] = "Label";
colType = "Character";
colModel = "Nominal";
colFormat = Format("Best");
colNames[i] = "Start_Time";
colType = "Numeric";
colModel = "Continuous";
<STRONG>colFormat = Format("m/d/y h:m:s", 23, 0);
newCol << Get Format = Format("Best", 10);</STRONG>
colNames[i] = "End_Time";
colType = "Numeric";
colModel = "Continuous";
<STRONG>colFormat = Format("m/d/y h:m:s", 23, 0);
newCol << Get Format = Format("Best", 10);</STRONG>ボーナスフォローアップ質問:列が初期化された後にタイプを設定した上記のコードを使用してのみ、列データとモデリングタイプを設定できるようです。 以下の行を実行しようとすると、列が初期化されないのはなぜですか?
newCol = summaryTable << New Column( colNames[i], colType, colModel );
スクリプティングRe:JSLは列フォーマットを設定しません皆さんありがとう。 テーブルをコピーして行を削除することを検討しました。 データテーブルは約2ダースの列で構成され、数百行になる可能性があります。 数百行を削除するよりも、2ダースの列を繰り返し作成する方が効率的かもしれないと考えました。@pmrozのサブセットアプローチは賢いですが、私はそれを使うかもしれません。
Re:JSLは列フォーマットを設定しませんテーブルが大きくなく、Markの考えに基づいていると仮定すると、代わりに次のようにすることができます。
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Eval(dt << getScript);
dt2 << selectAllRows;
dt2 << deleteRows;Re: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");
Re:JSLは列フォーマットを設定しません返信ありがとうございます。 「データ」は、複数のSQLクエリと計算から作成された既存のテーブルであるとは言いませんでした。 実際にサブセット化せずに、「データ」と同じ列のサマリーテーブルを作成したいと思います。 後で区分的に行を埋めます。
@pmrozあなたのアプローチはうまくいきます、ありがとう! なぜポインタが動かないのかはまだわかりませんが、これでもう気になりません。
Re: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));
);
);Re:JSLは列フォーマットを設定しません元のデータテーブルのコピーを保存し、コピーを開いて続行する方が簡単でしょうか?
Re: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 ) /*###*/
{}