Subscribe Bookmark RSS Feed

Opening files not supported by JMP

natalie_

Community Trekker

Joined:

Jan 6, 2016

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" )

  )

  )

  )}

)

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

You do not need a table property to do this. A new table is created automatically by Open().

file = Pick File();

dt = Open(file, ...);

4 REPLIES
Solution

You do not need a table property to do this. A new table is created automatically by Open().

file = Pick File();

dt = Open(file, ...);

msharp

Super User

Joined:

Jul 28, 2015

And the Russians used a pencil.

To expand on MS's answer.  Open() takes a wide variety of options and delimitation can be specified in every way imaginable.  For more information Search Open in the Scripting Index.  Example 2 will probably be most beneficial.

Of course since you already have all the open properties specified from the script above.  Just delete this portion of your code:

dt=New Table();

dt << Add Properties to Table(

  {New Script(

  "Source",

and the subsequent ")})" that goes with it.

Of course, I'm pretty sure you could optimize the code, I doubt there's a need to specify the columns.

natalie_

Community Trekker

Joined:

Jan 6, 2016

Thank you, I didn't realize it would be that simple.

natalie_

Community Trekker

Joined:

Jan 6, 2016

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" )

  ));