Subscribe Bookmark RSS Feed

Import with EOF Other

dayvie

Community Trekker

Joined:

Jan 21, 2014

I am making a script to import a set of txt files into a single table.  I can get the data in the format I need when importing manually by delimiting on "Tab" and "|".   However, the script I have only works if I use only End Of Line(Tab).   Everytime I add End Of Line(Other) it fails, am I not writing the EOFOther script correctly?

path = "C:\File Location\";

y = Files In Directory( path );

n = N Items( y );

//Make list y1 of open() expressions

y1 = {};

For( i = 1, i <= n, i++,

  y1 = Parse(

  Eval Insert(

  "Open(path||\!"^y^\!",

  Import Settings(

  Number of Columns(35)

  End Of Line( CRLF, CR, LF ),

  End Of Field( Tab, Other ),

  EOF Other("|"),

  Strip Quotes( 0 ),

  Use Apostrophe as Quotation Mark( 0 ),

  Scan Whole File( 1 ),

  Labels( 1 ),

  Column Names Start(5),

  Data Starts( 6 ),

  Lines To Read( All )

  ))"

  )

  )

);

// (Open and) Concatenate files

Eval( y1[1] ) << Concatenate(

  Eval List( y1[2 :: n] ),

);

//Close sub-files

For( i = 1, i <= n, i++,

  Close( Data Table( y ), nosave )

);

1 REPLY
dayvie

Community Trekker

Joined:

Jan 21, 2014

Ended up being a quotation error in my script, here is the working code:

For( i = 1, i <= n, i++,

  y1 = Parse(

  Eval Insert(

  "Open(parameterpath||\!"^y^\!",

  Import Settings(

  End Of Line( CRLF, CR, LF ),

  End Of Field( Tab, Other ),

  EOF Other( \!"|\!" ),

  Strip Quotes( 0 ),

  Use Apostrophe as Quotation Mark( 0 ),

  Scan Whole File( 1 ),

  Labels( 1 ),

  Column Names Start(5),

  Data Starts( 6 ),

  Lines To Read( All )

  ))"

  )

  )

);