For every .csv files in the input directory, create a Summary object. Using multiprocessing.pool create a pool for each Summary object and read the csv file using Pandas library. Pandas creates dataframe for each csv file, and combines them into one dataframe. Create a customer class for each order (not required in this coding challenge) which can help save information for each customer, and gives the flexibility to performs actions on single customer. Based on user's input on promotions type, calculate the results.
Pandas library is used to read csv and convert into dataframe. More info - https://github.com/pandas-dev/pandas
>>> pip install -r requirements.txt
Two ways to run the application-
- Using command line with options
>>> python ./main.py --input-path input --promotion-type rebate_scheme --output-path output/output.csv
- :param --input-path : Absolute path to input directory where .csv files reside
- :param --promotion-type : Type of promotion
- :param --output-path : Absolute path to output file to store results
not mandatory
- Using .cfg file
Update configuration in config/args.cfg file
>>> python -m src.app
The application prints the output as required to stdout. Also, the application writes the output to output/output.csv file as well. Currently, it just prints the columns organ, cash, price, bonus_ratio, bonus_results. The big_orders.csv contains orders of million count. To test with this file, move the file to input directory and run the application.
To run tests using Pytest -
>>> pytest -q --input-path="tests" --promotion-type="rebate_scheme" --output-path="tests/output/test_output.csv"
- :param --input-path : Absolute path to input directory where test .csv files reside
- :param --promotion-type : Type of promotion
- :param --output-path : Absolute path to output file to store test results
not mandatory
More info on pytest - https://docs.pytest.org/en/6.2.x/contents.html