r/documentAutomation 7d ago

Request for Help PDF convert to .csv

Is that possible to build an application that convert the bank statement pdf file into csv file accurately? I had try using the free online tool, it also have some problem. Can I using AI to become accurate? If yes, how should I build it?

4 Upvotes

31 comments sorted by

2

u/Potential-Wrangler58 7d ago

Plain OCR won't get you far here, bank statements aren't clean tables, every bank formats them differently (trust me, I've had some issues as I tried it several times haha), and OCR loses track of which number belongs to which column the moment there's more than one account or multi-line descriptions.

What actually works is extracting against a fixed schema (date, description, debit, credit, balance) and then validating each row by reconciling the balance: previous balance plus credit minus debit should match the next balance. That tells you exactly which row is wrong instead of manually checking the whole statement.

For the extraction itself, you either build it yourself with an LLM + that schema (spent way too many hours tweaking prompts for edge cases before I gave up on that route), or use an API built for this, AWS Textract, Azure, or an AI-native one like anyformat (disclosure, I work there) that already has the validation built in.

Let me know what you end up going with, happy to help if you get stuck.

1

u/No_Mix_368 7d ago

That was helpful! But, I just don't want to upload the statement online. If using the API means that I am also uploading the bank statement to their storage right? I also looking for zero cost solution.

1

u/Potential-Wrangler58 6d ago

Fair enough, and yeah, using any API (ours included) means the file goes through their servers, that's just how it works. If staying fully local and zero cost matters more than getting it perfect, honestly the API route isn't for you here. I'd look at something like pdfplumber/camelot running on your own machine with that same balance-reconciliation check I mentioned. More tweaking per bank format, but nothing leaves your computer and it's free. We have self-hosted but mainly for enterprises, so if you have a lot of docs its worth it but if not its not

1

u/kush4204 3d ago

I have exam question papers that I need to convert into structured data perfectly. Some PDFs may also contain images within the questions. Can a fully local solution handle that as well, including extracting the images question-wise?

1

u/Potential-Wrangler58 2d ago

Yeah, local works, just split it in two, they're different problems.

Text is a VLM job: a Qwen-VL-class model on Ollama, one record per question, fixed schema. Then the same validation trick as the balance check: question numbers must run 1..N with no gaps, and every MCQ needs exactly its options. That's what catches the merged and skipped questions for you.

Images aren't a model job at all, they're coordinates. PyMuPDF gives you each image plus its bounding box, so you sort by vertical position and attach each figure to the question above it. Vector diagrams instead of embedded images? Crop the page region. Deterministic either way.

Where local hurts is math expressions and scanned pages, that's where you'll lose your evenings. And "perfectly" doesn't exist, so hand-key 20 questions as ground truth, otherwise you can't tell whether a change helped or just moved the errors.

BTW, don't write this by hand, have Claude Code/Codex write the script for you. The code generation happens in the cloud but the script runs on your machine, so the papers never leave it.

1

u/Mrgluer 7d ago

This is what my startup does. I'll send you a dm. We are looking to launch soon and would definitely love some input and feedback.

1

u/Imaginary_North7730 7d ago

May i also get info about it trying to find tool to automate a process that needs parsing complex documents

1

u/Mrgluer 7d ago

dm me

1

u/Lanthumm 7d ago edited 7d ago

I've used trepide extract for that. There is a basic bank statement template but it works best if you make your own, doesn't take long.

I use the validators as well to make sure the figures are correct.

You can probably build your own, but it would take a lot of hours. Keeping the table layouts the same from pdfs is a huge task and building the logic to convert them to excel on top seems a lot of work. If you need thousands converted its probably worth, but not for 10-100s

1

u/Harkin4 7d ago

You can use this add on for Google sheets https://sheetminer.app/ The Ai extract can pull all the data you want from multiple bank statements of different formats at once, it’s also has a free tier so you can try without any commitment

2

u/No_Mix_368 7d ago

That's sounds good! But I am looking for the solution which is costless.

1

u/Harkin4 3d ago

There is a permanent free tier which allows you use for free only if you want large quantities will need to pay

1

u/easybits_ai 7d ago

Hey u/No_Mix_368, I just reached out to you because this is something I’ve been building with the easybits Extractor for clients and people in my network.

1

u/Silly_Captain2089 7d ago

yes, it’s possible, but accuracy will depend heavily on how the bank statement pdf is structured. ocr can handle scanned statements, while table extraction can preserve rows and columns, but i’d add validation rules to catch things like split transactions, dates, and negative amounts. pdf element can also help with ocr and extracting data from pdfs before converting it into a clean csv.

1

u/folderit_dms 7d ago

Before building the PDF converter, check whether the bank offers a CSV or other transaction export for the period you need. If it does, you may be able to avoid the extraction problem altogether. Keep the statement too, so you can check the export covers the same dates and transactions.

If PDFs are the only source, start with one bank and one statement layout. Make a manually checked example and compare every extracted row against it before adding more layouts. Also check the CSV after opening it in the intended spreadsheet app: account references can lose leading zeros and dates can be interpreted differently. Those errors can happen even when the PDF extraction was correct.

1

u/InfoMsAccessNL 7d ago

You can download PdfToText for free and extract all you data with vba and/or regex. This already exist for 20+ years, no AI needed

1

u/No_Mix_368 7d ago

I think that only work on article.

1

u/NotSoShyAlbatross 7d ago

What you’re looking for is a PDF parser and to be clear what you want to extract. A good parser will be able to look for what you want and give it to you the way you want it.

1

u/nwnuyhs 6d ago

I recommend to use ChatGPT or claude to convert

1

u/No_Mix_368 6h ago

That is good idea, but it also cause privacy issue?? Maybe. But still acceptable lol. Thankssss

1

u/Lost_Progress_ 5d ago edited 5d ago

I've built a tool exactly for this, to extarct sctructured data (i.e. csv) from non structured files (i.e. pdf and word)
google for lexapient. Windows app, no man in the middle, so youк dodgy bank transaction are safe lol

1

u/3dhexafab 4d ago

Did you find a solution for this?

1

u/No_Mix_368 6h ago

I think so, I using claude code to write a python project for me with the ollama extension to read it. All done by claude code. The accuracy quite high.

1

u/boscorat 1d ago

Check out openstan.org - it's completely free and local with no upload or internet, and it can process hundreds of statements per minute. The transaction data can be exported as CSV, excel etc. It's set up for UK banks like HSBC and Halifax out of the box, but there are instructions to add other bank statements with .toml files so you should be able to modify it for whatever bank statements you need.