cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pritzstik
Regular Visitor

Using AI Builder to extract data from PDFs

Hello!

 

I'm very new to Power Automate and Power Apps. I've built this flow in AI Builder to essentially extract 3 key pieces of data from multiple 6 page PDFs (there are 4000+ PDFs, and the layout on all of them is exactly the same) and then populate this information into a Google Sheet. (I use an =IMPORTRANGE to pull this information into another master spreadsheet).

 

The flow runs correctly, but then at a random point, it errors out, and comes up with the second attached error. I can't seem to find a solution anywhere for this and would really love some help understanding this and how to fix this. 

 

Am I just overloading it with too many PDF's to extract information from, or is there is a limitation somewhere in my flow?

 

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
JoeF-MSFT
Power Apps
Power Apps

Thanks @Pritzstik for the info!

 

I believe what is happening is that the Apply to each block is outside the Do until block. Apply to each needs to be inside Do until.

 

JoeFMSFT_0-1633472577505.png

 

View solution in original post

10 REPLIES 10
JoeF-MSFT
Power Apps
Power Apps

Thanks for the question and welcome to the Power Platform!

Looking at the error, it seems like the folder from where you are processing the PDFs also contains a Google Spreadsheet. The flow fails when it tries to download the spreadsheet which is not possible.

What you can do is add a condition that checks that the file to process is of type PDF, and that way it will not process other file types. This is how you can do it:

JoeFMSFT_0-1632950582527.png


I hope this helps!

Thanks so much! I rebuilt the flow according to your screenshot and it didn't fail, and I got a "Your flow ran successfully'!

However I have a second problem. I have 4,206 PDFs in the designated folder, but it's only populated information for 100 PDF's. Any ideas?

JoeF-MSFT
Power Apps
Power Apps

Great to hear that you got the flow to successfully run!

 

Unfortunately the List files in folder in Google Drive only returns a maximum of 100 files. But there is a workaround we can do that might work for you. 🙂 The process is to:

 

1. We iterate 100 files from folder A.

2. For every file we process we copy it to another folder B, and delete the file from the original folder A.

3. We repeat this process for 100 more files of folder A until there are no more files left once all have been processed and moved to folder B.

4. The flow stops running once there are no more files in folder A.

This is how you can build the flow to achieve it (you can click on the screenshot to see it bigger):

 

2021-09-30_23-30-35.png

 

 

Let us know if something is unclear.

Pritzstik
Regular Visitor

I modified the flow, but I think there's an issue with this. It seems to be working, but only for the first 100 files, so in effect, it's just going through the first 100 files multiple times, creating duplicate lines on the Google Sheet. The flow indicates it's copying the file into Folder B and then deleting it from Folder B. Should the flow not be deleting it from Folder A once it's copied over to Folder B?

JoeF-MSFT
Power Apps
Power Apps

Hi - thanks for the update!

 

Correct, on the Delete file action, make sure select the Id returned by the List files in folder (folder A) and not the Id returned by Create file action (folder B). 

 

JoeFMSFT_0-1633189929342.png

 

Pritzstik
Regular Visitor

Okay I got this to work. I was selecting the wrong Id tag. 

 

Final question? Do I have to run this flow every 100 files? The flow stopped (successfully) after the next 200 files. That's somewhat manual if I have 4000 files, I'd have to run the flow 40+ times.

JoeF-MSFT
Power Apps
Power Apps

Hi @Pritzstik - ask as many questions as needed. 🙂

 

The flow should run until it processes all 4,000 files. Can you check that the conditions are correctly set? Feel free to share a screenshot of your flow.

2021-09-30_23-30-35 (2).png

JoeF-MSFT
Power Apps
Power Apps

Hello again - one additional change is needed that I just realized.

On the Do until action, you will need to increase the Count option to a number equal or greater to the number of files you plan to process.

JoeFMSFT_0-1633381724839.png

 

Pritzstik
Regular Visitor

I changed the count but it's still completing successfully after just 100 files. Rest of the flow is attached. For context, this value was set at 60.I changed the count but it's still completing successfully after just 100 files. Rest of the flow is attached. For context, this value was set at 60.Screenshot 2021-10-05 at 10.26.12.pngScreenshot 2021-10-05 at 10.26.24.pngScreenshot 2021-10-05 at 10.26.30.png

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,680)