Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Batch macro using python tool - can't figure out how to pass / read different files

ck2024
9 - Comet

Hi guys

 

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.

 

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.  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:

 

Working python code

 

from ayx import Package
Package.installPackages(['pandas','numpy'])

from ayx import Alteryx

import pandas as pd
import pdfplumber


pdf = pdfplumber.open('c:/files/files/INVOICE_3660075585.pdf')
page = pdf.pages[0]
text = page.extract_text()
print(text)

page_df = pd.DataFrame([text])
Alteryx.write(page_df,1)

 

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?

 

any help would be appreciated... thank you

 

 

1 REPLY 1
Raj
14 - Magnetar
Labels