Ciao!
Ad esempio, se importo un file di testo come questo, se il mio file di testo ha un numero elevato di colonne,
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Save( "D:\Big.txt" );
Close( dt, nosave );
dt = Open(
"D:\Big.txt",
Charset( "gb2312" ),
columns(
New Column( "name", Character, "Nominal" ),
New Column( "age", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "sex", Character, "Nominal" ),
New Column( "height", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "weight", Numeric, "Continuous", Format( "Best", 12 ) )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 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" )
)
);
queste lettere ripetute possono essere sostituite da variabili?
abc="Numero, \!"Continuo\!", Formato( \!"Migliore\!", 12)"
dt = Open(
"D:\Big.txt",
Charset( "gb2312" ),
columns(
New Column( "name", Character, "Nominal" ),
New Column( "age",abc ),
New Column( "sex", Character, "Nominal" ),
New Column( "height",abc ),
New Column( "weight",abc )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 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" )
)
);
??
Grazie!
Puoi semplificare notevolmente la sceneggiatura: devi solo sperimentare ciò che è richiesto.Estrarrei sempre i riferimenti alle colonne e li elaborerei dopo l'importazione, per esempio:
dt = Open("$DOWNLOADS/Big Class.txt");
column(dt,"age") << set modeling type("nominal");