cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
BayesRabbit7133
Level III

group file name and set lable by JSL looping, work fine but slowly

I have a JLS works fine, but slowly, is there any method to improve it?

 

1. import multiple files

2. base on file name rule group into a, b, c, d, e 

3. base on file name rule to decide file count and set into rows for each group

Names Default To Here(1);
dir = Pick Directory( "Select a directory" );

Multiple File Import(
	<<Set Folder(
		dir
	),
	<<Set Show Hidden( 0 ),
	<<Set Subfolders( 0 ),
	<<Set Name Filter( "*.*;" ),
	<<Set Name Enable( 0 ),
	<<Set Size Filter( {1644369, 1653938} ),
	<<Set Size Enable( 0 ),
	<<Set Date Filter( {3783511548, 3783511550} ),
	<<Set Date Enable( 0 ),
	<<Set Add File Name Column( 1 ),
	<<Set Add File Size Column( 0 ),
	<<Set Add File Date Column( 0 ),
	<<Set Import Mode( "CSVData" ),
	<<Set Charset( "Best Guess" ),
	<<Set Stack Mode( "Stack Similar" ),
	<<Set CSV Has Headers( 1 ),
	<<Set CSV Allow Numeric( 1 ),
	<<Set CSV First Header Line( 2 ),
	<<Set CSV Number Of Header Lines( 1 ),
	<<Set CSV First Data Line( 3 ),
	<<Set CSV EOF Comma( 1 ),
	<<Set CSV EOF Tab( 1 ),
	<<Set CSV EOF Space( 1 ),
	<<Set CSV EOF Spaces( 1 ),
	<<Set CSV EOF Other( "" ),
	<<Set CSV EOL CRLF( 1 ),
	<<Set CSV EOL CR( 1 ),
	<<Set CSV EOL LF( 1 ),
	<<Set CSV EOL Semicolon( 0 ),
	<<Set CSV EOL Other( "" ),
	<<Set CSV Quote( "\!"" ),
	<<Set CSV Escape( "" ),
	<<Set XML Method( "guess" ),
	<<Set XML Guess( "huge" ),
	<<Set XML Settings( XML Settings() ),
	<<Set JSON Method( "guess" ),
	<<Set JSON Guess( "huge" ),
	<<Set JSON Settings( JSON Settings() ),
	<<Set Import Callback( Empty() )
) << Import Data;

dt = current data table();
filelist = Files In Directory(dir);
dt << new column("file_lable");
a_count = 0;
b_count = 0;
c_count = 0;
d_count = 0;
e_count = 0;
a_filelist = {};
b_filelist = {};
c_filelist = {};
d_filelist = {};
e_filelist = {};


for (i = 1, i <= N items(filelist), i++,

	a_files = contains(filelist[i],"a_");
	b_files = contains(filelist[i],"b_");
	c_files = contains(filelist[i],"c_");
	d_files = contains(filelist[i],"d_");
	e_files = contains(filelist[i],"e_");
	
	if ( a_files > 0, 
		insert into(a_filelist,filelist[i])
	);
	
	if ( b_files > 0, 
		insert into(b_filelist,filelist[i])
	);
	
	if ( c_files > 0, 
		insert into(c_filelist,filelist[i])
	);
	
	if ( d_files > 0, 
		insert into(d_filelist,filelist[i])
	);
	
	if ( e_files > 0, 
		insert into(e_filelist,filelist[i])
	);
);

	
for (i = 1, i <= N items(a_filelist), i++,
	is_reset_file = contains(a_filelist[i],"NULL");
	if( is_reset_file >= 1, 
		selrows = dt << get rows Where(Contains(char(a_filelist[i]), :File Name));
		column(dt,"file_lable")[selrows] = 0;
		b_count = 0;
	);
	if (is_reset_file == 0, 
		a_count = a_count + 1;
		selrows = dt << get rows Where(Contains(char(a_filelist[i]), :File Name));
		column(dt,"file_lable")[selrows] = a_count
	)
);

for (i = 1, i <= N items(b_filelist), i++,
	is_reset_file = contains(b_filelist[i],"NULL");
	if( is_reset_file >= 1, 
		selrows = dt << get rows Where(Contains(char(b_filelist[i]), :File Name));
		column(dt,"file_lable")[selrows] = 0;
		b_count = 0;
	);
	if (is_reset_file == 0, 
		b_count = b_count + 1;
		selrows = dt << get rows Where(Contains(char(b_filelist[i]), :File Name));
		column(dt,"file_lable")[selrows] = b_count
	)
);

// the following is loop for C , D, E

 

 

0 REPLIES 0