<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic group file name and set lable by JSL looping, work fine but slowly in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/group-file-name-and-set-lable-by-JSL-looping-work-fine-but/m-p/725024#M90894</link>
    <description>&lt;P&gt;I have a JLS works fine, but slowly, is there any method to improve it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. import multiple files&lt;/P&gt;&lt;P&gt;2. base on file name rule group into a, b, c, d, e&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. base on file name rule to decide file count and set into rows for each group&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dir = Pick Directory( "Select a directory" );

Multiple File Import(
	&amp;lt;&amp;lt;Set Folder(
		dir
	),
	&amp;lt;&amp;lt;Set Show Hidden( 0 ),
	&amp;lt;&amp;lt;Set Subfolders( 0 ),
	&amp;lt;&amp;lt;Set Name Filter( "*.*;" ),
	&amp;lt;&amp;lt;Set Name Enable( 0 ),
	&amp;lt;&amp;lt;Set Size Filter( {1644369, 1653938} ),
	&amp;lt;&amp;lt;Set Size Enable( 0 ),
	&amp;lt;&amp;lt;Set Date Filter( {3783511548, 3783511550} ),
	&amp;lt;&amp;lt;Set Date Enable( 0 ),
	&amp;lt;&amp;lt;Set Add File Name Column( 1 ),
	&amp;lt;&amp;lt;Set Add File Size Column( 0 ),
	&amp;lt;&amp;lt;Set Add File Date Column( 0 ),
	&amp;lt;&amp;lt;Set Import Mode( "CSVData" ),
	&amp;lt;&amp;lt;Set Charset( "Best Guess" ),
	&amp;lt;&amp;lt;Set Stack Mode( "Stack Similar" ),
	&amp;lt;&amp;lt;Set CSV Has Headers( 1 ),
	&amp;lt;&amp;lt;Set CSV Allow Numeric( 1 ),
	&amp;lt;&amp;lt;Set CSV First Header Line( 2 ),
	&amp;lt;&amp;lt;Set CSV Number Of Header Lines( 1 ),
	&amp;lt;&amp;lt;Set CSV First Data Line( 3 ),
	&amp;lt;&amp;lt;Set CSV EOF Comma( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Tab( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Space( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Spaces( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Other( "" ),
	&amp;lt;&amp;lt;Set CSV EOL CRLF( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL CR( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL LF( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL Semicolon( 0 ),
	&amp;lt;&amp;lt;Set CSV EOL Other( "" ),
	&amp;lt;&amp;lt;Set CSV Quote( "\!"" ),
	&amp;lt;&amp;lt;Set CSV Escape( "" ),
	&amp;lt;&amp;lt;Set XML Method( "guess" ),
	&amp;lt;&amp;lt;Set XML Guess( "huge" ),
	&amp;lt;&amp;lt;Set XML Settings( XML Settings() ),
	&amp;lt;&amp;lt;Set JSON Method( "guess" ),
	&amp;lt;&amp;lt;Set JSON Guess( "huge" ),
	&amp;lt;&amp;lt;Set JSON Settings( JSON Settings() ),
	&amp;lt;&amp;lt;Set Import Callback( Empty() )
) &amp;lt;&amp;lt; Import Data;

dt = current data table();
filelist = Files In Directory(dir);
dt &amp;lt;&amp;lt; 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 &amp;lt;= 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 &amp;gt; 0, 
		insert into(a_filelist,filelist[i])
	);
	
	if ( b_files &amp;gt; 0, 
		insert into(b_filelist,filelist[i])
	);
	
	if ( c_files &amp;gt; 0, 
		insert into(c_filelist,filelist[i])
	);
	
	if ( d_files &amp;gt; 0, 
		insert into(d_filelist,filelist[i])
	);
	
	if ( e_files &amp;gt; 0, 
		insert into(e_filelist,filelist[i])
	);
);

	
for (i = 1, i &amp;lt;= N items(a_filelist), i++,
	is_reset_file = contains(a_filelist[i],"NULL");
	if( is_reset_file &amp;gt;= 1, 
		selrows = dt &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; get rows Where(Contains(char(a_filelist[i]), :File Name));
		column(dt,"file_lable")[selrows] = a_count
	)
);

for (i = 1, i &amp;lt;= N items(b_filelist), i++,
	is_reset_file = contains(b_filelist[i],"NULL");
	if( is_reset_file &amp;gt;= 1, 
		selrows = dt &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; 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&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2024 08:24:11 GMT</pubDate>
    <dc:creator>BayesRabbit7133</dc:creator>
    <dc:date>2024-02-22T08:24:11Z</dc:date>
    <item>
      <title>group file name and set lable by JSL looping, work fine but slowly</title>
      <link>https://community.jmp.com/t5/Discussions/group-file-name-and-set-lable-by-JSL-looping-work-fine-but/m-p/725024#M90894</link>
      <description>&lt;P&gt;I have a JLS works fine, but slowly, is there any method to improve it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. import multiple files&lt;/P&gt;&lt;P&gt;2. base on file name rule group into a, b, c, d, e&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. base on file name rule to decide file count and set into rows for each group&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dir = Pick Directory( "Select a directory" );

Multiple File Import(
	&amp;lt;&amp;lt;Set Folder(
		dir
	),
	&amp;lt;&amp;lt;Set Show Hidden( 0 ),
	&amp;lt;&amp;lt;Set Subfolders( 0 ),
	&amp;lt;&amp;lt;Set Name Filter( "*.*;" ),
	&amp;lt;&amp;lt;Set Name Enable( 0 ),
	&amp;lt;&amp;lt;Set Size Filter( {1644369, 1653938} ),
	&amp;lt;&amp;lt;Set Size Enable( 0 ),
	&amp;lt;&amp;lt;Set Date Filter( {3783511548, 3783511550} ),
	&amp;lt;&amp;lt;Set Date Enable( 0 ),
	&amp;lt;&amp;lt;Set Add File Name Column( 1 ),
	&amp;lt;&amp;lt;Set Add File Size Column( 0 ),
	&amp;lt;&amp;lt;Set Add File Date Column( 0 ),
	&amp;lt;&amp;lt;Set Import Mode( "CSVData" ),
	&amp;lt;&amp;lt;Set Charset( "Best Guess" ),
	&amp;lt;&amp;lt;Set Stack Mode( "Stack Similar" ),
	&amp;lt;&amp;lt;Set CSV Has Headers( 1 ),
	&amp;lt;&amp;lt;Set CSV Allow Numeric( 1 ),
	&amp;lt;&amp;lt;Set CSV First Header Line( 2 ),
	&amp;lt;&amp;lt;Set CSV Number Of Header Lines( 1 ),
	&amp;lt;&amp;lt;Set CSV First Data Line( 3 ),
	&amp;lt;&amp;lt;Set CSV EOF Comma( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Tab( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Space( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Spaces( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Other( "" ),
	&amp;lt;&amp;lt;Set CSV EOL CRLF( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL CR( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL LF( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL Semicolon( 0 ),
	&amp;lt;&amp;lt;Set CSV EOL Other( "" ),
	&amp;lt;&amp;lt;Set CSV Quote( "\!"" ),
	&amp;lt;&amp;lt;Set CSV Escape( "" ),
	&amp;lt;&amp;lt;Set XML Method( "guess" ),
	&amp;lt;&amp;lt;Set XML Guess( "huge" ),
	&amp;lt;&amp;lt;Set XML Settings( XML Settings() ),
	&amp;lt;&amp;lt;Set JSON Method( "guess" ),
	&amp;lt;&amp;lt;Set JSON Guess( "huge" ),
	&amp;lt;&amp;lt;Set JSON Settings( JSON Settings() ),
	&amp;lt;&amp;lt;Set Import Callback( Empty() )
) &amp;lt;&amp;lt; Import Data;

dt = current data table();
filelist = Files In Directory(dir);
dt &amp;lt;&amp;lt; 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 &amp;lt;= 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 &amp;gt; 0, 
		insert into(a_filelist,filelist[i])
	);
	
	if ( b_files &amp;gt; 0, 
		insert into(b_filelist,filelist[i])
	);
	
	if ( c_files &amp;gt; 0, 
		insert into(c_filelist,filelist[i])
	);
	
	if ( d_files &amp;gt; 0, 
		insert into(d_filelist,filelist[i])
	);
	
	if ( e_files &amp;gt; 0, 
		insert into(e_filelist,filelist[i])
	);
);

	
for (i = 1, i &amp;lt;= N items(a_filelist), i++,
	is_reset_file = contains(a_filelist[i],"NULL");
	if( is_reset_file &amp;gt;= 1, 
		selrows = dt &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; get rows Where(Contains(char(a_filelist[i]), :File Name));
		column(dt,"file_lable")[selrows] = a_count
	)
);

for (i = 1, i &amp;lt;= N items(b_filelist), i++,
	is_reset_file = contains(b_filelist[i],"NULL");
	if( is_reset_file &amp;gt;= 1, 
		selrows = dt &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; 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&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 08:24:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/group-file-name-and-set-lable-by-JSL-looping-work-fine-but/m-p/725024#M90894</guid>
      <dc:creator>BayesRabbit7133</dc:creator>
      <dc:date>2024-02-22T08:24:11Z</dc:date>
    </item>
  </channel>
</rss>

