Hi all,
I'm a scripting idiot and need a hand for accomplishing a simple task. I need a script that allows a user to select a single directory, looks for CSV files in the directory, and appends/concatenates the files into a single JMP datatable. For now, it's fine if this "master datatable" gets rebuilt with the CSV files in the directory every time the user runs the script.
I did some research and found something from resident super-user genius txnelson that should accomplish the task, but when I run it, I receive an error and I don't understand why. The script:
Names Default To Here( 1 );
// Setup an empty table to start to concatenate other tables to
dtbase = New Table( "Base Table" );
// Have the user select the starting folder
dirpath = Pick Directory( "Pick the Top Level Directory" );
// Get all of the files in all of the folders that are under the picked folder
TheFileList = Files In Directory( dirpath, "recursive" );
// Go through all of the files and read in append those that meet your
// requirement. You will need to amend the IF statement to meet your criteria
For( i = 1, i <= N Items( TheFileList ), i++,
If( Uppercase( Word( -1, TheFileList, "." ) ) == "CSV" & Is File( dirpath || TheFileList ) == 1,
dt = Open( dirpath || TheFileList );
dtbase = dtbase << concatenate( dt, append to first table( 1 ) );
Close( dt, nosave );
);
);When I run the script, it runs until I select the directory, and then nothing happens. I stepped through the code and here is where the error is thrown:
argument should be character in access or evaluation of 'Word' , Bad Argument( TheFileList ), Word/*###*/(-1, TheFileList, ".")
I don't understand what this jargon means. The code seems to make sense. Why won't it work?
Thanks and sorry for being an idiot.