<?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 macro using python tool - can't figure out how to pass / read different files in Alteryx Designer Desktop Discussions</title>
    <link>https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Batch-macro-using-python-tool-can-t-figure-out-how-to-pass-read/m-p/1267558#M316232</link>
    <description>&lt;P&gt;Hi guys&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been able to get this to work to read the contents of the PDF liberating someones pdf macro tool that was no longer working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, for whatever reason i couldn't get it to read the incoming files from the input tool - I resorted to referencing a file name specifically and i got that working.&amp;nbsp; What would be the process to iterate through the folders - i was going to use a batch macro which would update based on the contents of a directory tool but i couldn't get that far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working python code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from ayx import Package&lt;BR /&gt;Package.installPackages(['pandas','numpy'])&lt;/P&gt;&lt;P&gt;from ayx import Alteryx&lt;BR /&gt;&lt;BR /&gt;import pandas as pd&lt;BR /&gt;import pdfplumber&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;pdf = pdfplumber.open('c:/files/files/INVOICE_3660075585.pdf')&lt;BR /&gt;page = pdf.pages[0]&lt;BR /&gt;text = page.extract_text()&lt;BR /&gt;print(text)&lt;/P&gt;&lt;P&gt;page_df = pd.DataFrame([text])&lt;BR /&gt;Alteryx.write(page_df,1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also I don't think my pdfs run to 2 pages, but if they did, how would i update the code to grab more than one page?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any help would be appreciated... thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2024 11:27:33 GMT</pubDate>
    <dc:creator>ck2024</dc:creator>
    <dc:date>2024-04-30T11:27:33Z</dc:date>
    <item>
      <title>Batch macro using python tool - can't figure out how to pass / read different files</title>
      <link>https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Batch-macro-using-python-tool-can-t-figure-out-how-to-pass-read/m-p/1267558#M316232</link>
      <description>&lt;P&gt;Hi guys&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been able to get this to work to read the contents of the PDF liberating someones pdf macro tool that was no longer working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, for whatever reason i couldn't get it to read the incoming files from the input tool - I resorted to referencing a file name specifically and i got that working.&amp;nbsp; What would be the process to iterate through the folders - i was going to use a batch macro which would update based on the contents of a directory tool but i couldn't get that far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working python code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from ayx import Package&lt;BR /&gt;Package.installPackages(['pandas','numpy'])&lt;/P&gt;&lt;P&gt;from ayx import Alteryx&lt;BR /&gt;&lt;BR /&gt;import pandas as pd&lt;BR /&gt;import pdfplumber&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;pdf = pdfplumber.open('c:/files/files/INVOICE_3660075585.pdf')&lt;BR /&gt;page = pdf.pages[0]&lt;BR /&gt;text = page.extract_text()&lt;BR /&gt;print(text)&lt;/P&gt;&lt;P&gt;page_df = pd.DataFrame([text])&lt;BR /&gt;Alteryx.write(page_df,1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also I don't think my pdfs run to 2 pages, but if they did, how would i update the code to grab more than one page?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any help would be appreciated... thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 11:27:33 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Batch-macro-using-python-tool-can-t-figure-out-how-to-pass-read/m-p/1267558#M316232</guid>
      <dc:creator>ck2024</dc:creator>
      <dc:date>2024-04-30T11:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Batch macro using python tool - can't figure out how to pass / read different files</title>
      <link>https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Batch-macro-using-python-tool-can-t-figure-out-how-to-pass-read/m-p/1267802#M316311</link>
      <description>&lt;P&gt;&lt;a href="https://community.alteryx.com/t5/user/viewprofilepage/user-id/80437"&gt;@ck2024&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;is this the same case&lt;BR /&gt;&lt;A href="https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Passing-different-filenames-into-python-tool-to-convert-PDFs-to/td-p/1267599" target="_blank"&gt;Passing different filenames into python tool to co... - Alteryx Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 17:51:03 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Batch-macro-using-python-tool-can-t-figure-out-how-to-pass-read/m-p/1267802#M316311</guid>
      <dc:creator>Raj</dc:creator>
      <dc:date>2024-04-30T17:51:03Z</dc:date>
    </item>
  </channel>
</rss>

