<?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 How to import multiple pdf files into data table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343222#M59242</link>
    <description>&lt;P&gt;Warning: I am new to scripting&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Challenge&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I have about 500 pdf files, each containing a data table I want to import to JMP and collate into a single jmp data table.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Work flow &amp;amp; issues&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I made a script (see below) that allows me to import the tabulated data from one pdf and append it to a table I called &lt;EM&gt;Final.jmp&lt;/EM&gt;. I kept the script as a separate file, i.e. not inside a data table. Each pdf is appended to &lt;EM&gt;Final.jmp&lt;/EM&gt; as a single row.&lt;/LI&gt;&lt;LI&gt;After each import, I have to close the &lt;EM&gt;Final.jmp&lt;/EM&gt; table and overwrite it with the new, updated "final" table that contains the extra row from the newly imported pdf.&lt;/LI&gt;&lt;LI&gt;After each import I also have to manually close all the intermediate tables being created in the process. (boring)&lt;/LI&gt;&lt;LI&gt;Then I change the pdf file name in the script, press save and re-run it to import yet another pdf. And so the cycles continues.&lt;/LI&gt;&lt;LI&gt;This process is faster than manual copy pasting, but still laborious and with near certainty not automated to a degree typical for computer science.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Is it possible to have a script run repetitively, each time selecting a new pdf for import and append it to the same table until all pdfs in one folder have been imported?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open(
	"C:\example folder\example.pdf",
	PDF Tables(
		Table(
			table name( "1" ),
			add rows( page( 1 ), Rect( 2.0419, 0.9776, 3.1993, 1.1726 ) ),
			add rows( page( 1 ), Rect( 1.2137, 3.7819, 6.3603, 3.9069 ) ),
			add rows( page( 1 ), Rect( 0.8717, 3.9636, 3.0796, 4.0886 ) ),
			add rows(
				page( 1 ),
				Rect( 0.9853, 4.1436, 3.0029, 4.2686 ),
				column borders( 0.9853, 2.5416, 3.0029 )
			),
			add rows( page( 1 ), Rect( 4.581, 4.1436, 7.297, 4.2686 ) ),
			add rows(
				page( 1 ),
				Rect( 0.8883, 4.4136, 4.6374, 4.5386 ),
				column borders( 0.8883, 1.9603, 4.6374 )
			),
			add rows(
				page( 1 ),
				Rect( 6.0143, 4.6569, 7.2498, 4.7819 ),
				column borders( 6.0143, 6.5817, 7.2498 )
			),
			add rows( page( 1 ), Rect( 0.7556, 4.7979, 7.5908, 8.2654 ) )
		)
	)
);

Data Table( "1" ) &amp;lt;&amp;lt; Stack(
	columns( :Column 3, :Column 4, :Column 5, :Column 6 ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Output table("2")
);

Data Table( "2" ) &amp;lt;&amp;lt; Transpose(
	columns( :Data ),
	Output Table( "3" )
);

Data Table( "Final" ) &amp;lt;&amp;lt; Concatenate( Data Table( "3" ) )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:24:01 GMT</pubDate>
    <dc:creator>Ressel</dc:creator>
    <dc:date>2023-06-10T23:24:01Z</dc:date>
    <item>
      <title>How to import multiple pdf files into data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343222#M59242</link>
      <description>&lt;P&gt;Warning: I am new to scripting&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Challenge&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I have about 500 pdf files, each containing a data table I want to import to JMP and collate into a single jmp data table.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Work flow &amp;amp; issues&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I made a script (see below) that allows me to import the tabulated data from one pdf and append it to a table I called &lt;EM&gt;Final.jmp&lt;/EM&gt;. I kept the script as a separate file, i.e. not inside a data table. Each pdf is appended to &lt;EM&gt;Final.jmp&lt;/EM&gt; as a single row.&lt;/LI&gt;&lt;LI&gt;After each import, I have to close the &lt;EM&gt;Final.jmp&lt;/EM&gt; table and overwrite it with the new, updated "final" table that contains the extra row from the newly imported pdf.&lt;/LI&gt;&lt;LI&gt;After each import I also have to manually close all the intermediate tables being created in the process. (boring)&lt;/LI&gt;&lt;LI&gt;Then I change the pdf file name in the script, press save and re-run it to import yet another pdf. And so the cycles continues.&lt;/LI&gt;&lt;LI&gt;This process is faster than manual copy pasting, but still laborious and with near certainty not automated to a degree typical for computer science.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Is it possible to have a script run repetitively, each time selecting a new pdf for import and append it to the same table until all pdfs in one folder have been imported?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open(
	"C:\example folder\example.pdf",
	PDF Tables(
		Table(
			table name( "1" ),
			add rows( page( 1 ), Rect( 2.0419, 0.9776, 3.1993, 1.1726 ) ),
			add rows( page( 1 ), Rect( 1.2137, 3.7819, 6.3603, 3.9069 ) ),
			add rows( page( 1 ), Rect( 0.8717, 3.9636, 3.0796, 4.0886 ) ),
			add rows(
				page( 1 ),
				Rect( 0.9853, 4.1436, 3.0029, 4.2686 ),
				column borders( 0.9853, 2.5416, 3.0029 )
			),
			add rows( page( 1 ), Rect( 4.581, 4.1436, 7.297, 4.2686 ) ),
			add rows(
				page( 1 ),
				Rect( 0.8883, 4.4136, 4.6374, 4.5386 ),
				column borders( 0.8883, 1.9603, 4.6374 )
			),
			add rows(
				page( 1 ),
				Rect( 6.0143, 4.6569, 7.2498, 4.7819 ),
				column borders( 6.0143, 6.5817, 7.2498 )
			),
			add rows( page( 1 ), Rect( 0.7556, 4.7979, 7.5908, 8.2654 ) )
		)
	)
);

Data Table( "1" ) &amp;lt;&amp;lt; Stack(
	columns( :Column 3, :Column 4, :Column 5, :Column 6 ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Output table("2")
);

Data Table( "2" ) &amp;lt;&amp;lt; Transpose(
	columns( :Data ),
	Output Table( "3" )
);

Data Table( "Final" ) &amp;lt;&amp;lt; Concatenate( Data Table( "3" ) )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:24:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343222#M59242</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2023-06-10T23:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple pdf files into data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343288#M59247</link>
      <description>&lt;P&gt;All that has to be done is to just loop across the code, reading in one file after another and adding it to the Final data table.&amp;nbsp; The JSL below should provide you with a good start on how to do this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);

// Here is an example where the first thing that is done, is to create
// the list of the files to be processed
// Many different methods can be used to do this, but for this example
// the file names are read in from a directory

theFilesList = Files in directory( &amp;lt;path to your folder that has the .pdf files&amp;gt; );

// Create the Final data table that will have all of the processed files 
// concatenated to it
Data Table( "Final" );

// Loop across all of the files and read them in one at a time and add them
// to the Final data table
For( i = 1, i &amp;lt;= N Items( theFilesList ), i++,
	Open(
		theFilesList[i],
		PDF Tables(
			Table(
				table name( "1" ),
				add rows( page( 1 ), Rect( 2.0419, 0.9776, 3.1993, 1.1726 ) ),
				add rows( page( 1 ), Rect( 1.2137, 3.7819, 6.3603, 3.9069 ) ),
				add rows( page( 1 ), Rect( 0.8717, 3.9636, 3.0796, 4.0886 ) ),
				add rows( page( 1 ), Rect( 0.9853, 4.1436, 3.0029, 4.2686 ), column borders( 0.9853, 2.5416, 3.0029 ) ),
				add rows( page( 1 ), Rect( 4.581, 4.1436, 7.297, 4.2686 ) ),
				add rows( page( 1 ), Rect( 0.8883, 4.4136, 4.6374, 4.5386 ), column borders( 0.8883, 1.9603, 4.6374 ) ),
				add rows( page( 1 ), Rect( 6.0143, 4.6569, 7.2498, 4.7819 ), column borders( 6.0143, 6.5817, 7.2498 ) ),
				add rows( page( 1 ), Rect( 0.7556, 4.7979, 7.5908, 8.2654 ) )
			)
		)
	);

	Data Table( "1" ) &amp;lt;&amp;lt; Stack(
		columns( :Column 3, :Column 4, :Column 5, :Column 6 ),
		Source Label Column( "Label" ),
		Stacked Data Column( "Data" ),
		Output table( "2" )
	);

	Data Table( "2" ) &amp;lt;&amp;lt; Transpose( columns( :Data ), Output Table( "3" ) );

// Concatenate the processed data to the Final data table
	Data Table( "Final" ) &amp;lt;&amp;lt; Concatenate( Data Table( "3" ), Append to first table( 1 ) );

// Cleanup the environment
	Close( Data Table( "1" ), nosave );
	Close( Data Table( "2" ), nosave );
	Close( Data Table( "3" ), nosave );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Dec 2020 17:11:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343288#M59247</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-12-19T17:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple pdf files into data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343289#M59248</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;, I don't know how to adequately express my gratitude. You are very, very kind. Thank you so much for your help again!&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 17:22:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343289#M59248</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2020-12-19T17:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple pdf files into data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343292#M59249</link>
      <description>&lt;P&gt;Sorry, I have to return with yet more questions because somehow, despite years of academic training, I cannot get this loop to function. Here's what I tried to make it work: First I moved all files to my local hard disk, because for some reason we are using "()" in some of our folder names on the server and I had the impression this was creating an issue. Eventually, I "quoted" the whole directory in the script using&amp;nbsp; quotation marks, which seemed to convince the script to run until the next error message. Then it told me something about "Path is invalid ...'Glue' ...". I googled it, but have no idea how to address that issue. I can see that the file name in the error message is the name of one of the files in the directory I want to work with. First I thought the hyphen in the file name was creating an issue, but even when changing that the error occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have pasted in below:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;A copy of the script with a fake directory name. I preserved the number of folders as well as the folder name containing parentheses.&lt;/LI&gt;&lt;LI&gt;The error message from the script window&lt;/LI&gt;&lt;LI&gt;The error message from debugging&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Also, how do I include the directory AND filename in the final data table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance! (If you find this too trivial to answer, I will understand.)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ressel_0-1608408948210.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29048i8EB183C71DC82D2E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ressel_0-1608408948210.png" alt="Ressel_0-1608408948210.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ressel_1-1608408956917.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29049iA0DFB9259C02FBC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ressel_1-1608408956917.png" alt="Ressel_1-1608408956917.png" /&gt;&lt;/span&gt;&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);

// Here is an example where the first thing that is done, is to create
// the list of the files to be processed
// Many different methods can be used to do this, but for this example
// the file names are read in from a directory

theFilesList = Files in directory( "C:\directory1\subdirectory1\subdirectory2\subdirectory3 (nameof aperson)\subdirectory4\subdirectory5\subdirectory6\subdirectory7\subdirectory8\subdirectory9\subdirectory10" );

// Create the Final data table that will have all of the processed files 
// concatenated to it
Data Table( "Final" );

// Loop across all of the files and read them in one at a time and add them
// to the Final data table
For( i = 1, i &amp;lt;= N Items( theFilesList ), i++,
	Open(
		theFilesList[i],
		PDF Tables(
			Table(
				table name( "1" ),
				add rows( page( 1 ), Rect( 2.0419, 0.9776, 3.1993, 1.1726 ) ),
				add rows( page( 1 ), Rect( 1.2137, 3.7819, 6.3603, 3.9069 ) ),
				add rows( page( 1 ), Rect( 0.8717, 3.9636, 3.0796, 4.0886 ) ),
				add rows( page( 1 ), Rect( 0.9853, 4.1436, 3.0029, 4.2686 ), column borders( 0.9853, 2.5416, 3.0029 ) ),
				add rows( page( 1 ), Rect( 4.581, 4.1436, 7.297, 4.2686 ) ),
				add rows( page( 1 ), Rect( 0.8883, 4.4136, 4.6374, 4.5386 ), column borders( 0.8883, 1.9603, 4.6374 ) ),
				add rows( page( 1 ), Rect( 6.0143, 4.6569, 7.2498, 4.7819 ), column borders( 6.0143, 6.5817, 7.2498 ) ),
				add rows( page( 1 ), Rect( 0.7556, 4.7979, 7.5908, 8.2654 ) )
			)
		)
	);

	Data Table( "1" ) &amp;lt;&amp;lt; Stack(
		columns( :Column 3, :Column 4, :Column 5, :Column 6 ),
		Source Label Column( "Label" ),
		Stacked Data Column( "Data" ),
		Output table( "2" )
	);

	Data Table( "2" ) &amp;lt;&amp;lt; Transpose( columns( :Data ), Output Table( "3" ) );

// Concatenate the processed data to the Final data table
	Data Table( "Final" ) &amp;lt;&amp;lt; Concatenate( Data Table( "3" ), Append to first table( 1 ) );

// Cleanup the environment
	Close( Data Table( "1" ), nosave );
	Close( Data Table( "2" ), nosave );
	Close( Data Table( "3" ), nosave );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 20:16:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343292#M59249</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2020-12-19T20:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple pdf files into data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343293#M59250</link>
      <description>&lt;P&gt;My error........&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data table( "Final" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should have been specified&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Final" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Dec 2020 20:58:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-import-multiple-pdf-files-into-data-table/m-p/343293#M59250</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-12-19T20:58:33Z</dc:date>
    </item>
  </channel>
</rss>

