Forum Discussion
Extract data from PDFS where data not uniform
Hi, I need to loop through some PDFs. While much of the data is uniform, some lines are not. I have figured out how to use power query to extract data from individuals PDFs, therefore accouting differences between files, but not sure how to create a loop with conditional logic? to deal with each PDF?
Thank you,
Steve
5 Replies
- vicky_Super User
There isn't really a way to loop through conditions, however, there are some ways around it.
The easiest built-in method is to use the folder connector - https://learn.microsoft.com/en-us/power-query/connectors/folder. You can try put all your PDFs in the same folder, and then transform one of them. Once you load it into your data, the transformation will be applied to all PDFs in the file. With this method, the same tranformations are applied to all files in the folder, so there's not a lot of flexibility.Otherwise, there are ways to write functions in M - this will be a bit more involved coding-wise. I recommend checking out https://blog.crossjoin.co.uk/2016/05/15/creating-m-functions-from-parameterised-queries-in-power-bi/ and https://learn.microsoft.com/en-us/power-query/custom-function for more details.
- se2Helper II
Thank you, I will try
- se2Helper II
OK. I think I will create a custom query and use parameters if needed. Will add conditional columns to bring in irregular data. Still not sure how to loop through the files in a folder and apply the custom query to each file.
- se2Helper II
looks like loops are in m-code but not in the power question menu.
- AnonymousNot applicable
Hi se2 ,
Whether the advice given by vicky_ has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.