This script works very nicely to open all the files in a directory, filter them based upon some criteria and then Concatenate all of the files.
=====================================================================================================
path = "C:\temp\data\";
file_list = {};
file_list = Files in Directory(path, recursive);
myFiles = file_list;
For( i = 1, i <= N Items( file_list ), i++,
If( Contains( file_list, ".sum" ),
myFiles = ""
)
);
final_files = myfiles;
///////////////////Open First File in List/////////////////////
///////additional files will be appended to this one///////////
i=1;
dtjoin = Open(
path || final_files,
columns(
Pass_Fail = Character,
Parameter = Character,
Data_Value = Numeric,
Units = Character,
LSL = Numeric,
USL = Numeric,
Note = Character,
Test_Cond = Character
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, Other( "0x7c" ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
Labels( 1 ),
Column Names Start( 1 ),
Data Starts( 2 ),
Lines To Read( All ),
Year Rule( "20xx" )
),
)
<< set name( "Joined1" );
////////////////////////////////////////////////////////////////////////////
//////////Now open the remaining Files in List//////////////
////////////////////////////////////////////////////////////////////////////
i=2;
For( i = 2, i <= N Items( final_files ), i++,
dt =
Open(
path || final_files,
columns(
Pass_Fail = Character,
Parameter = Character,
Data_Value = Numeric,
Units = Character,
LSL = Numeric,
USL = Numeric,
Note = Character,
Test_Cond = Character
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, Other( "0x7c" ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
Labels( 1 ),
Column Names Start( 1 ),
Data Starts( 2 ),
Lines To Read( All ),
Year Rule( "20xx" )
)
);
dtjoin = dtjoin << Concatenate(
dt,
output table name( "Joined" || Char( i ) ),
);
Close( dt, nosave);
Close( "Joined" || Char( i - 1 ), nosave );
Wait( 0.1 );
); //End of For
dtjoin << set name( "All Joined" );