#README#
#Python 3.6.1
- Excel Parser with disk-file as well as with Bytes and unit testing for the parser.
#What is this repo#
- This is the code to parse excel data, which will have item and availableStock column.
It reads and parse it to namedtuple, right now we are catching only
itemandavailableStockif there are more parameters, then we can handle them as well, also we can trigger somer alerts if they are missing, as per our requirements. - In this demo we are dealing with disk-file, but I have shown you how you can deal with bytes as well by converting disk-file to bytes.
- Right now we are dealing everything with simple python script inclusing testing, later we will switch to some framework like django/flask as per requirement.
#Sample excel file is also kept in BASE_DIR sample.xlsx for reference.
sample.xlsxfile is used for testing the code.- Code is flak8 tested.
- Create virtual environment and install requirements from
production.txtfor prod env andtest.txtfor testing. base.txtis common requirements for both prod and test env.
#Run the Code
- CD to BASE_DIR ie.. parser folder.
- Run
python excel_parser.py /path/to/excel/file. - To see the output in text file run
python excel_parser.py /path/to/excel/file > output.txtExample:python excel_parser.py 'sample.xlsx' > output.txt - You will see a file
output.txtwith output data.
#Run Test Case
- CD to BASE_DIR ie.. in parser folder.
python test.pyif there is any error it will throw it on console.- or you can try
python test.py > test.txtto see the output. - To test flake8
flake8 excel_parser.pyor simpleflake8.