cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
vharibal
Level II

Selecting only csv files using jsl

Hi,
I have folder with multiple folders and csv files. I would like to open only csv files and concatenate them without opening folders

I tried using Files in Directory function and opening files from folder but this opens the folders as well

Can some one please help me on this?
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Selecting only csv files using jsl

You can easily filter the list of files returned from Files in Directory, to return only .csv files

Names Default To Here( 1 );
files = Files In Directory( "C:\Program Files\JMP\JMPPRO\18\Samples\Import Data", recursive( 0 ) );
onlycsv = Filter Each( {x}, files, contains(x,".csv"));

You may also want to look into using Multiple File Import.  If your .csv files are similar MFI can automatically concatenate them for you

Names Default To Here( 1 );

mfi = Multiple File Import();
mfi << Set Folder( "$SAMPLE_IMPORT_DATA" );
mfi << Set Name Filter( "*.csv" );
mfi << Set Name Enable( 1 );
mfi << Set Stack Mode( "Stack Similar" );
mfi << Set Subfolders( 0 );
tables = mfi << Import Data();
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Selecting only csv files using jsl

You can easily filter the list of files returned from Files in Directory, to return only .csv files

Names Default To Here( 1 );
files = Files In Directory( "C:\Program Files\JMP\JMPPRO\18\Samples\Import Data", recursive( 0 ) );
onlycsv = Filter Each( {x}, files, contains(x,".csv"));

You may also want to look into using Multiple File Import.  If your .csv files are similar MFI can automatically concatenate them for you

Names Default To Here( 1 );

mfi = Multiple File Import();
mfi << Set Folder( "$SAMPLE_IMPORT_DATA" );
mfi << Set Name Filter( "*.csv" );
mfi << Set Name Enable( 1 );
mfi << Set Stack Mode( "Stack Similar" );
mfi << Set Subfolders( 0 );
tables = mfi << Import Data();
Jim
vharibal
Level II

Re: Selecting only csv files using jsl

Thank you so much.

It worked.