#πŸ”’ Recommend me a library, or some tip to get this table correctly

16 messages Β· Page 1 of 1 (latest)

young lynx
#

I have more documents like this and most online services which I assume use python behind get the same problem on the second to last line

wide wedgeBOT
#

@young lynx

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

mild creek
young lynx
#

I need to extract that table as a .csv, using python, but most of the online tools I've tried mess the second to lasst line since it priorizes layout over different text color, so it looks like:

Usos: Abastecimiento,Riego | Hidroelectrico

That's because they look at it this way:

#

Now, I would like to know what's a good python library for this, because I'm pretty sure most will look at the table the same way, first they try to think of a layout and wathever falls on one side is considered part of one column, now I have more pdf documents like this, so manually correcting this would be a long task, so I wonder if some library will have mor granular control or will be clever enough to notice each text has different color and therefore is a different column

mild creek
#

tbh, idk what a ,csv file is probably not the right guy to be answering this, gl tho

#

lowkey tho throw it into chat

cold shadow
# young lynx I need to extract that table as a .csv, using python, but most of the online too...

I've dealt with something like this before. As long as you can get the text left -> right then top -> bottom, and as long as everything is single line, and as long as : is always used only as the separator, simply splitting lines on : will work. I had to do a lot more work since my data had multi-line entries. I used PyMuPDF since as long as the PDF has the text as some sort of actual text, it is the most consistent library I have found for the left -> right then top -> bottom text extraction.

young lynx
#

For pdfs with text I've used pypdf and pdfminer, both are very nice, I had also heard about pyMuPDF before, hope that one works

cold shadow
#

Since I have already struggled with this a lot, feel free to ping me whever you need help/open another one of these issues. I'd be my pleasure to help someone else out of the PDF hellscape.

#

There is also always the nuclear option of extractDict, which gives you basically all the information possible, including stuff like font and color, which would almost certainly work based on how those images look, but would also be the hardest to work with.

wide wedgeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.