Something like this might work.
// use MFI to stack a mixed bag of tables...
// assumes "text" and "file name" are not columns in the data AND assumes
// no commas in the data values. Not sure how you would work around that.
dir = "$temp/testfiles/"; // make sample files here
Delete Directory( dir );
Create Directory( dir );
Save Text File( dir || "a.csv", "a,b,c\!n1,2,3\!n-1,-2,-3" );
Save Text File( dir || "b.csv", "junk\!nc,b,a,e\!n3,4,5,98\!n-1,-2,-3,-4" );
Save Text File( dir || "c.csv", "junk\!njunk\!nb,d,a,c\!n6,99,7,8\!n-1,-2,-3,-4" );
dtList = Multiple File Import(
<<Set Folder( dir ),
<<Set Add File Name Column( 1 ),
<<Set Import Mode( "Row Per Line" ),
<<Set Stack Mode( "Stack Similar" )
) << Import Data;
dt = dtList[1];
// clean up "junk". It might not be this simple for your data...
dt << selectwhere( Contains( text, "junk" ) );
dt << deleterows;
// hunt for unique column names
headerrows = dt << getrowswhere( Row() == 1 | FileName[Row()] != FileName[Row() - 1] );
uniquecols = Associative Array( Words( Concat Items( Transform Each( {header}, dt[headerrows, {text}], header[1] ), "," ), "," ) ) << getkeys;
// add the unique column names, character data for now...
For Each( {cname}, uniquecols, dt << New Column( cname, character ) );
// transfer data from text to unique cols.
headerrows |/= N Rows( dt ) + 1; // append sentinel
For( iheader = 1, iheader < N Rows( headerrows ), iheader += 1,
cols = Words( dt:text[headerrows[iheader]], "," );
startrow = headerrows[iheader] + 1;
stoprow = headerrows[iheader + 1] - 1;
For( irow = startrow, irow <= stoprow, irow += 1,
dt[irow, cols] = Words( dt:text[irow], "," )
);
);
// remove the headers and left over bits
dt << selectrows( headerrows[1 :: N Rows( headerrows ) - 1] );
dt << deleterows;
dt << delete columns( {text, file name} );
dt << delete scripts( "files" );
dt << delete scripts( "source" );
cleaned up
Now you'll have to decide which columns are numeric...
Craige