<?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 Re: Log Compiler in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827396#M100905</link>
    <description>&lt;P&gt;Multiple File Import might help, either by importing and stacking CSV or by loading the unprocessed text into a row per file. Play with the GUI then save the script if you get something you like. If you can use file time stamps, it will help there too.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jan 2025 23:17:21 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2025-01-14T23:17:21Z</dc:date>
    <item>
      <title>Log Compiler</title>
      <link>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827347#M100898</link>
      <description>&lt;P&gt;I have a script that compiles a group of log files depending on the title of the files in the source directory.&amp;nbsp; This script reads in a Lot ID from an address table and uses that to search the path directory "dir" and compile the target files.&amp;nbsp; I need to repurpose this script where I would like the script to look inside the text of the available files to see if the lot ID shows up there and compiles accordingly.&amp;nbsp; I saw some references to this online but the idea of opening every file to make the determination seems like something that could take a long time.&amp;nbsp; Ideas appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Clear Globals();

lst = Column( "lot" ) &amp;lt;&amp;lt; Get Values;

n = N Items( lst );

dir = "\\Source_Directory\";

myfiles = {};

files = Files In Directory( dir, Recursive );

n_getfiles = N Items( files );

filteredFiles = {};

While( (testname = Remove From( files, 1 )) != {}, 

	Relevant = Char( Regex( testname[1], "/4(\d{6})R", "4\1" ) );

If( Contains( testname[1], Relevant ),

		Insert Into( filteredFiles, testname, 1 );

	);
);

Show( filteredFiles );

t_filterfiles = t4 - t3;

n_filterfiles = N Items( filteredFiles );

Show( t_getfiles, n_getfiles, t_filterfiles, n_filterfiles );

Show( filteredFiles );

compiler_function = Function( {lot_number}, 

	Try(
		use1 = lot_number;
		LotID = Char( use1 );

		For( i = 1, i &amp;lt;= N Items( filteredFiles ), i++, 
			If( Contains( filteredFiles[i], LotID ), 
				Insert Into( myFiles, filteredFiles[i] ))
		);
		final_files = myfiles;
	)
);

For( l = 1, l &amp;lt;= n, l++, //Show(l);
	compiler_function( lst[l] )
);

i = 1;

dtjoin = Open(

	dir || myfiles[i], 

	Import Settings(
		End Of Line( CRLF, CR, LF ),
		End Of Field( Tab, Comma, CSV( 1 ) ),
		Strip Quotes( 1 ),
		Use Apostrophe as Quotation Mark( 0 ),
		Use Regional Settings( 0 ),
		Scan Whole File( 1 ),
		Treat empty columns as numeric( 0 ),
		CompressNumericColumns( 0 ),
		CompressCharacterColumns( 0 ),
		CompressAllowListCheck( 0 ),
		Labels( 1 ),
		Column Names Start( 1 ),
		First Named Column( 1 ),
		Data Starts( 2 ),
		Lines To Read( "All" ),
		Year Rule( "20xx" )
	);
	
	
);
Wait( 0 );
Column( 1 ) &amp;lt;&amp;lt; set name( "Column 1" );
dtjoin &amp;lt;&amp;lt; set name( "Joined1" );
dtjoin &amp;lt;&amp;lt; Add Rows( 1, after( N Rows( dtjoin ) ) );
For( i = N Rows( dtjoin ), i &amp;lt;= N Rows( dtjoin ), i++,
	:Column 1[i] = "File 1"
);

i = 2;

For( i = 2, i &amp;lt;= N Items( myfiles ), i++, 

	dt = Open(

		dir || myfiles[i], 

		Import Settings(
			End Of Line( CRLF, CR, LF ),
			End Of Field( Tab, Comma, CSV( 1 ) ),
			Strip Quotes( 1 ),
			Use Apostrophe as Quotation Mark( 0 ),
			Use Regional Settings( 0 ),
			Scan Whole File( 1 ),
			Treat empty columns as numeric( 0 ),
			CompressNumericColumns( 0 ),
			CompressCharacterColumns( 0 ),
			CompressAllowListCheck( 0 ),
			Labels( 1 ),
			Column Names Start( 1 ),
			First Named Column( 1 ),
			Data Starts( 2 ),
			Lines To Read( "All" ),
			Year Rule( "20xx" )
		);

	);
        
	Column( 1 ) &amp;lt;&amp;lt; set name( "Column 1" );
	dt &amp;lt;&amp;lt; Add Rows( 1, after( N Rows( dt ) ) );
	For( j = N Rows( dt ), j &amp;lt;= N Rows( dt ), j++,
		:Column 1[j] = ("File " || Char( i ))
	);
 
	dtjoin = dtjoin &amp;lt;&amp;lt; Concatenate(
		dt, output table name( "Joined" || Char( i ) ), 
	);

	Close( dt, nosave );

	Close( "Joined" || Char( i - 1 ), nosave );

	Wait( 0.1 );

); 

dtjoin &amp;lt;&amp;lt; set name( " Mask Data" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jan 2025 16:14:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827347#M100898</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2025-01-14T16:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Log Compiler</title>
      <link>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827357#M100899</link>
      <description>&lt;P&gt;How large files do you have? How many files? Can the ID be anywhere in the file or in specific location/line? What have you tried (for example &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/file-functions.shtml?os=win&amp;amp;source=application#ww4957499" target="_self"&gt;Load Text File()&lt;/A&gt;)?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 16:18:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827357#M100899</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-14T16:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Log Compiler</title>
      <link>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827358#M100900</link>
      <description>&lt;P&gt;Files come out at ~25kB, 300-400 lines long, number of files can vary, maybe 100 worst case.&amp;nbsp; Anything I considered would have had to have opened each file to decide relevance, I didn't write anything like that, I might expire before the data arrives.&amp;nbsp; Load Text File() looks interesting, I'll have a tinker with that.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 16:41:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827358#M100900</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2025-01-14T16:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Log Compiler</title>
      <link>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827396#M100905</link>
      <description>&lt;P&gt;Multiple File Import might help, either by importing and stacking CSV or by loading the unprocessed text into a row per file. Play with the GUI then save the script if you get something you like. If you can use file time stamps, it will help there too.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 23:17:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Log-Compiler/m-p/827396#M100905</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-01-14T23:17:21Z</dc:date>
    </item>
  </channel>
</rss>

