JSL legt das Spaltenformat nicht festHallo alle,
Ich versuche, die Spaltennamen, Datentypen, Modellierungstypen und Formate von einer Tabelle in eine neue zu kopieren, aber wenn ich versuche, das Spaltenformat festzulegen, dauert es nie und kehrt einfach zu "Best" zurück. Ich schlage mir schon seit einiger Zeit den Kopf dagegen und bin völlig ratlos, warum es nicht funktioniert. Unten ist mein Code und die resultierende Ausgabe, die zeigt, dass das Spaltenformat gültig ist, aber einfach nicht bleibt. Im Protokoll sind keine Fehler gemeldet. Kann jemand sehen, was ich falsch mache?
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>Bonus-Folgefrage : Ich kann die Spaltendaten und Modellierungstypen nur mit dem obigen Code festlegen, wobei ich die Typen nach der Initialisierung der Spalte festlege. Wenn ich versuche, die folgende Zeile auszuführen, werden die Spalten einfach nicht initialisiert, warum nicht?
newCol = summaryTable << New Column( colNames[i], colType, colModel );
SkripterstellungBetreff: JSL legt das Spaltenformat nicht festDanke an alle. Ich überlegte, die Tabelle zu kopieren und Zeilen zu löschen. Die Datentabelle besteht aus etwa 2 Dutzend Spalten und kann möglicherweise Hunderte von Zeilen enthalten. Ich dachte, das iterative Erstellen von 2 Dutzend Spalten könnte effizienter sein, als möglicherweise Hunderte von Zeilen zu löschen.@pmroz Der Subset-Ansatz von ist jedoch clever, ich könnte ihn einfach verwenden.
Betreff: JSL legt das Spaltenformat nicht festAngenommen, der Tisch ist nicht riesig und aufbauend auf Marks Gedanken, könnten Sie es alternativ so machen:
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Eval(dt << getScript);
dt2 << selectAllRows;
dt2 << deleteRows;Betreff: JSL legt das Spaltenformat nicht festEinfachere Logik, die eine Teilmenge verwendet:
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");
Betreff: JSL legt das Spaltenformat nicht festDanke für die Antworten. Ich glaube, ich habe nicht erwähnt, dass "Daten" eine bereits vorhandene Tabelle ist, die aus mehreren SQL-Abfragen und -Berechnungen erstellt wurde. Ich möchte eine Übersichtstabelle mit denselben Spalten wie "Daten" zusammenstellen, ohne sie tatsächlich zu unterteilen. Später fülle ich die Reihen stückweise auf.
@pmroz Dein Ansatz funktioniert, danke! Ich verstehe immer noch nicht, warum der Zeiger nicht funktioniert, aber ich bin so darüber hinweg, dass es mir egal ist.
Betreff: JSL legt das Spaltenformat nicht festDieser Code wird es tun:
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));
);
);Betreff: JSL legt das Spaltenformat nicht festWäre es einfacher, eine Kopie der ursprünglichen Datentabelle zu speichern und die Kopie zu öffnen, um fortzufahren?
Betreff: JSL legt das Spaltenformat nicht festHallo,
Erstens denke ich, dass "Daten" nicht definiert sind.
Clear Globals();
summaryTable = New Table( "Results Summary" );
colNames = data << Get Column Names( string );
Ergebnis ist
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 ) /*###*/
{}