<?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 Batch processing files to extract data into a summary table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529021#M75250</link>
    <description>&lt;P&gt;I have multiple files that I want to perform some analysis on. I want to create a loop to open the file, perform the analysis, calculate a value "area under a curve" in this example and then make a summary table with the file name and area. I can open the files from a folder and perform the analysis. I am not sure how to create the summary table. I have given an example with 2 files but I have many more files I would like to process in this way. Any help or guidance is greatly appreciated! Also please let me know if this does not make sense or if more information is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//point to file directory

path = Pick Directory( "Select Directory Containing Data Files" );

//Gets the list of files in the selected file folder
file_list = Files In Directory( path );

//i=0;open file
nfile_list = N Items( file_list );
For( i = 1, i &amp;lt;= nfile_list, i += 1, 
	//Set Current Directory( dir_DirectoryPath );
	dt = Open( path || file_list[i], );
	//Calculate area
	dt = Current Data Table();
	dt &amp;lt;&amp;lt; clear row states;
	obj3 = dt &amp;lt;&amp;lt; Bivariate(
		Y( :Name( "Data" ) ),
		X( :Time ),
		Fit Polynomial( 6, {Line Color( {212, 73, 88} )} ),
		SendToReport( Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 449, 411 )} ) )
	);
	//save graph to data dable
	obj3 &amp;lt;&amp;lt; Save Script to Data Table( "Area" );
	//get the prediction formula string and calculate the area under the curve for 30 minute adsoription
	fm = Report( obj3 )[Outline Box( "Polynomial ?" )][Text Edit Box( 1 )] &amp;lt;&amp;lt; get text;
	//get the string to the right of the equal sign and convert the string to an expression using Parse()
	fm = Parse( Trim( Word( 2, fm, "=" ) ) );
	area = Integrate( fm, :Time, 0, 3600 );
	Caption( "The area under this curve is " || Char( area ) );
	Print( area );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example of Final Table I would like to have:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thedellette_0-1659380880942.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/44458i380B1E95E0124B75/image-size/medium?v=v2&amp;amp;px=400" role="button" title="thedellette_0-1659380880942.png" alt="thedellette_0-1659380880942.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help with this would be greatly appreciated. Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 17:06:12 GMT</pubDate>
    <dc:creator>thedellette</dc:creator>
    <dc:date>2023-06-09T17:06:12Z</dc:date>
    <item>
      <title>Batch processing files to extract data into a summary table</title>
      <link>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529021#M75250</link>
      <description>&lt;P&gt;I have multiple files that I want to perform some analysis on. I want to create a loop to open the file, perform the analysis, calculate a value "area under a curve" in this example and then make a summary table with the file name and area. I can open the files from a folder and perform the analysis. I am not sure how to create the summary table. I have given an example with 2 files but I have many more files I would like to process in this way. Any help or guidance is greatly appreciated! Also please let me know if this does not make sense or if more information is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//point to file directory

path = Pick Directory( "Select Directory Containing Data Files" );

//Gets the list of files in the selected file folder
file_list = Files In Directory( path );

//i=0;open file
nfile_list = N Items( file_list );
For( i = 1, i &amp;lt;= nfile_list, i += 1, 
	//Set Current Directory( dir_DirectoryPath );
	dt = Open( path || file_list[i], );
	//Calculate area
	dt = Current Data Table();
	dt &amp;lt;&amp;lt; clear row states;
	obj3 = dt &amp;lt;&amp;lt; Bivariate(
		Y( :Name( "Data" ) ),
		X( :Time ),
		Fit Polynomial( 6, {Line Color( {212, 73, 88} )} ),
		SendToReport( Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 449, 411 )} ) )
	);
	//save graph to data dable
	obj3 &amp;lt;&amp;lt; Save Script to Data Table( "Area" );
	//get the prediction formula string and calculate the area under the curve for 30 minute adsoription
	fm = Report( obj3 )[Outline Box( "Polynomial ?" )][Text Edit Box( 1 )] &amp;lt;&amp;lt; get text;
	//get the string to the right of the equal sign and convert the string to an expression using Parse()
	fm = Parse( Trim( Word( 2, fm, "=" ) ) );
	area = Integrate( fm, :Time, 0, 3600 );
	Caption( "The area under this curve is " || Char( area ) );
	Print( area );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example of Final Table I would like to have:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thedellette_0-1659380880942.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/44458i380B1E95E0124B75/image-size/medium?v=v2&amp;amp;px=400" role="button" title="thedellette_0-1659380880942.png" alt="thedellette_0-1659380880942.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help with this would be greatly appreciated. Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:06:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529021#M75250</guid>
      <dc:creator>thedellette</dc:creator>
      <dc:date>2023-06-09T17:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Batch processing files to extract data into a summary table</title>
      <link>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529057#M75253</link>
      <description>&lt;P&gt;Before you start looping, create new table with File Name and Area columns and format them as you want them to be. Easiest way is to create new table and then use Copy Table Script. Also remember to assign reference variable to that table!&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1659383448197.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/44460i4B20F5F5C0651EB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1659383448197.png" alt="jthi_0-1659383448197.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then in the loop after you have calculated the area you can get&amp;nbsp; the table name by using &amp;lt;&amp;lt; Get Name and then add the new rows to your collection table with &amp;lt;&amp;lt; Add Rows(). Also remember to close unnecessary tables and reports after getting the relevant information from them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt_collector = New Table("Untitled",
	Add Rows(0),
	New Column("File Name", Character, Nominal, Set Values({})),
	New Column("Area", Numeric, "Continuous",  Set Values([]))
);

// For(..
//	...
	//dt_name = dt &amp;lt;&amp;lt; Get Name;
	dt_name = "table";
	area = 123;
	dt_collector &amp;lt;&amp;lt; Add Row({File Name = dt_name, Area = area});
//);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 19:55:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529057#M75253</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-08-01T19:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Batch processing files to extract data into a summary table</title>
      <link>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529064#M75254</link>
      <description>&lt;P&gt;I have added code that will create a new data table, and will write the file name and area to the new table&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );
//point to file directory

path = Pick Directory( "Select Directory Containing Data Files" );

//Gets the list of files in the selected file folder
file_list = Files In Directory( path );

// Crete beginnings of output data table
dtFinal = New Table( "Final", New Column( "File Name", Character ), New Column( "Area" ) );

//i=0;open file
nfile_list = N Items( file_list );
For( i = 1, i &amp;lt;= nfile_list, i += 1, 
	//Set Current Directory( dir_DirectoryPath );
	dt = Open( path || file_list[i], );
	//Calculate area
	dt = Current Data Table();
	dt &amp;lt;&amp;lt; clear row states;
	obj3 = dt &amp;lt;&amp;lt; Bivariate(
		invisible,
		Y( :Name( "Data" ) ),
		X( :Time ),
		Fit Polynomial( 6, {Line Color( {212, 73, 88} )} ),
		SendToReport( Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 449, 411 )} ) )
	);
	//save graph to data dable
	obj3 &amp;lt;&amp;lt; Save Script to Data Table( "Area" );
	//get the prediction formula string and calculate the area under the curve for 30 minute adsoription
	fm = Report( obj3 )[Outline Box( "Polynomial ?" )][Text Edit Box( 1 )] &amp;lt;&amp;lt; get text;
	//get the string to the right of the equal sign and convert the string to an expression using Parse()
	fm = Parse( Trim( Word( 2, fm, "=" ) ) );
	area = Integrate( fm, :Time, 0, 3600 );
	Caption( "The area under this curve is " || Char( area ) );
	Print( area );
	
	// Add information to Final data table
	dtFinal &amp;lt;&amp;lt; add rows( 1 );
	dtFinal:File Name[N Rows( dtFinal )] = file_list[i];
	dtFinal:area[N Rows( dtFinal )] = area;
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Aug 2022 20:04:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529064#M75254</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-08-01T20:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Batch processing files to extract data into a summary table</title>
      <link>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529135#M75262</link>
      <description>&lt;P&gt;Thank you! You gave a nice detailed explanation as well. Easy to follow :)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 22:36:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529135#M75262</guid>
      <dc:creator>thedellette</dc:creator>
      <dc:date>2022-08-01T22:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Batch processing files to extract data into a summary table</title>
      <link>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529137#M75263</link>
      <description>&lt;P&gt;Thank you! I saw the other reply first but I like this one as well.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 22:37:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Batch-processing-files-to-extract-data-into-a-summary-table/m-p/529137#M75263</guid>
      <dc:creator>thedellette</dc:creator>
      <dc:date>2022-08-01T22:37:44Z</dc:date>
    </item>
  </channel>
</rss>

