Program for processing input files in the format of receipts.
computeSales.py
reads .txt
files, makes correctness check, and can print requested statistics.
-------------------
AFM:AAAAAAAA
PRODUCT_NAME: QUANTITY UNIT_PRICE TOTAL_VALUE
...
PRODUCT_NAME: QUANTITY UNIT_PRICE TOTAL_VALUE
TOTAL: TOTAL VALUE
--------------------
AFM:AAAAAAAB
PRODUCT_NAME: QUANTITY UNIT_PRICE TOTAL_VALUE
...
PRODUCT_NAME: QUANTITY UNIT_PRICE TOTAL_VALUE
TOTAL: TOTAL VALUE
--------------------
A sample of a good receipt
--------------------------
ΑΦΜ: 0123456789
ΧΩΡΙΑΤΙΚΗ: 2 5.50 11.00
ΚΡΕΑΤΑ: 4 12.25 49.00
ΚΡΑΣΙ: 2 3.50 7.00
ΣΥΝΟΛΟ: 67.00
--------------------------
ΑΦΜ: 0123456780
ΧΩΡΙΑΤΙΚΗ: 2 2.00 4.00
ΚΡΕΑΤΑ: 4 12.00 48.00
ΣΥΝΟΛΟ: 52.00
--------------------------
.TXT files 1:
- 1 or more receipts in file(but at least 1)
- Begins/Ends with lines containing the ‘-’ character.
- Separated by lines containing the ‘-’ character.
- First line contains the AFM number(10-digit number).
- Last line contains the total purchases.
- There can be receipts of different companies (AFM).
- Receipts of multiple products (1 or more).
- Reappearance of a product in a receipt. 2
- No problem with space characters in receipts
- Error in receipt => receipt ignored => file preserved
Prints the following user menu repeatedly3:
- Read input file4.
- Print statistics for a specific product.
- Print statistics for a specific AFM.
- In Linux
- Refresh repository lists
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
- Install latest versions of python
$ sudo apt-get install python3.8
- Verify installation and compile
$ python3.8
$ python3.8 computeSales.py
- In any python IDE
- Install Python packages from website
https://www.python.org/downloads/
and choose version 5
- Install Pycharm (or any Python Platform you are familiar with)
- Import project to PyCharm workspace
- Make sure you have python interpreter detected (or install it)
- Run your
computeSales.py
Footnotes
-
Every input file satisfies constraints about numerical values and format it sustains. ↩
-
In the proof, the product XORIATIKI may appear again later in the same proof. ↩
-
There must be data in order to be able to be read (or input files). ↩
-
The program works for a non-specific archive length. ↩
-
Make sure you include python version as PATH variable. Select it on installation process ↩