#๐Ÿ”’ [Niche] Is this PDF file parsable?

69 messages ยท Page 1 of 1 (latest)

neat yew
#

If anyone is proficient in parsing PDFs, can you give me an idea of if this PDF is parsable? I want to extract the questions and possible answers for the multiple choice section into either text, json, or (preferably) some sort of markup like HTML.

karmic palmBOT
#

@neat yew

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.

tiny prawn
#

!rule ai

karmic palmBOT
#

10. Do not copy and paste answers from ChatGPT or similar AI tools.

unique grotto
#

sorry

#

I didn't copy and paste btw. It was the actual chat

tiny prawn
#

You could've said "I tried ai and it seems it extracted data, so the file is certainly parseable" ๐Ÿ˜‰ but without actually verifying the result, you don't know whether it did the job fully correctly, hence I brought up the rule

unique grotto
#

I said ChatGPT can, I didn't pretend I wrote it myself

#

and a link to the actual ChatGPT chat

#

The result was also in the Chat so no need to write a moral essay thanks

neat yew
#

Bump?

unique grotto
#

did you try PyPDF2?

neat yew
#

BTW I tried uploading it to ChatGPT and it thought I was talking about a facility in Paris

unique grotto
#

I got it to work in ChatGPT

#

or rather it made it work

#

but it was just using PyPDF2

#

and iterating over the results

#

nothing too fancy

neat yew
# unique grotto did you try PyPDF2?

I'm not interested in trying anything unless someone who has done something similar (extract text from a complex pdf) before tells me it might work because it'll be a lot of effort

#

But I would use something like PyPDF

unique grotto
#

it's 3 lines of code

neat yew
#

My use case would not be

unique grotto
#

I mean extracting text is no more than 3 lines of code

neat yew
#

I have to extract stoichiometry equations and relate every question to its answers

#

And parse said stoichiometry equations into HTML

unique grotto
#

I mean once you have it as text the rest should be fairly easy

neat yew
#

Outputs the following text:

COLLISION ONE COLLISION TWO
BEFORE
COLLISION COLLISION AFTER
COLLISION BEFORE
COLLISION COLLISION AFTER
COLLISION
N
O O
F F
F F
N
O O
N
O O
F
F
F F
O O
N
F F
O O
N
F F
O
N
O
unique grotto
#

yeah that bit requires a bit more parsing

neat yew
#

So for these ones I need to take screenshots

#

I don't think there's any other way

unique grotto
#

if you want to display it exactly like in the pdf probably yeah

neat yew
#

Yeah :(

unique grotto
#

even if you had that a structured data

#

unless you're a front end wiz

#

which I'm not

#

but the rest should be doable

neat yew
#

When I was parsing these by hand I just made a table and slapped some <img> tags in it

unique grotto
#

yeah could be an option

#

or you could play with react component but it would take you a long time

#

if you're not super experienced

neat yew
#

I'm no front-end wiz either

#

I'm using HTMX

unique grotto
#

interesting

#

never tried it before but looks super cool from what I read

neat yew
#

This is a proof of concept with only 7 questions so you'll see duplicates

unique grotto
#

looks cool

neat yew
#

Any thoughts for improvement?

unique grotto
#

when I hover over the answer

neat yew
#

Oh, you want like a clicky cursor or something?

unique grotto
#

there should be a way for the user to figure out that you can click on them

neat yew
#

Sounds good

unique grotto
#

yeah it looks like free form text this way

#

or maybe have the letters bigger so it's clear you need to click on them

#

but something to make it more obvious that it's clickable

#

the rest looks good

neat yew
#

Okay I updated it

unique grotto
#

yeah better

#

how about a tick box on the side?

neat yew
#

What do you mean by tick box?

#

Because usually you tick a box if you're planning on submitting something in the future

unique grotto
#

checkbox sory

neat yew
#

But here it submits right away

unique grotto
#

true

#

maybe a button then that you just press

#

anyways it's a moot point tbh

karmic palmBOT
#
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.