<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi everyone,
I need to open .wat files. I am able to manually import it into a data table, and I do this by using delimited fields with Space and Spaces. I can copy script:
Add Properties to Table(
{New Script(
"Source",
Open(
"C:\Users\user\Downloads\B8A17901.WAT",
columns(
Column( "Column 1", Numeric, "Continuous", Format( "Best", 10 ) ),
Column( "W.A.T.", Character, "Nominal" ),
Column( "DATA", Character, "Nominal" ),
Column( "ATTACHED", Character, "Nominal" ),
Column( "c000005", Character, "Nominal" ),
Column( "c000006", Character, "Nominal" ),
Column( "c000007", Character, "Nominal" ),
Column( "c000008", Character, "Nominal" ),
Column( "c000009", Character, "Nominal" ),
Column( "c0000010", Character, "Nominal" ),
Column( "c0000011", Character, "Nominal" ),
Column( "c0000012", Character, "Nominal" ),
Column( "c0000013", Character, "Nominal" )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Spaces, Space, 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" )
)
)
)}
)
But what I really want to do is write a script that does this, but I am not sure what it is I am doing wrong. I am selecting a file, creating a new data table and adding properties to that data table. Any ideas? Thanks!
file = Pick File();
dt=New Table();
dt << Add Properties to Table(
{New Script(
"Source",
Open(
file,
columns(
Column( "Column 1", Numeric, "Continuous", Format( "Best", 10 ) ),
Column( "W.A.T.", Character, "Nominal" ),
Column( "DATA", Character, "Nominal" ),
Column( "ATTACHED", Character, "Nominal" ),
Column( "c000005", Character, "Nominal" ),
Column( "c000006", Character, "Nominal" ),
Column( "c000007", Character, "Nominal" ),
Column( "c000008", Character, "Nominal" ),
Column( "c000009", Character, "Nominal" ),
Column( "c0000010", Character, "Nominal" ),
Column( "c0000011", Character, "Nominal" ),
Column( "c0000012", Character, "Nominal" ),
Column( "c0000013", Character, "Nominal" )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Spaces, Space, 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" )
)
)
)}
)
Thank you! I thought I had to add the properties for some reason. It is way simpler this way.
file = Pick File();
dt = Open(file,
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Spaces, Space, 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" )
));