#๐ Python & receipts
20 messages ยท Page 1 of 1 (latest)
@plucky blaze
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.
I am working on a project that focus on analyze tickets from a supermarket
The data analysis is on R, but the structure of the tickets it's a little bit weird and I thought that changing it could make easier to work on them later
The tickets are originally .PDF, but with a little bit of coding, I could made them into .txt
Here's a picture of one of the tickets as .txt
The six first lines are already processed and they do not need any work. The seventh line represent the format in which the data below is shown (th products purchased)
Quantity, description, Price by unit, Total
The problem is that some items do not have a price by unit, and I would like to transfer the ticket to a new .txt where, if it does not have price by unit, it shows NA
Another problem comes down in lines 27 and 29, where the kilograms (quantity), price by kilograms (price by unit) and total it's on the next line.
This happens when its products like fruit, that price varies depending of the amount you get
Here's my code, which is only made for one ticket for now
total_pattern = re.compile(r"TOTAL \(\x80\) \d+,\d{2}") This represents the line where the line of products ends, which varies depending on what ticket youre working with. The encoding is latin1, and x80 represents the euro symbol
Thank you very much for anyone reading this, if I'm not explaining myself, please let me know
Analyzing receipts for Data Science
@plucky blaze
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.