Question
BACKGROUND: You have been hired by the ACME Supply Corporation to write a program to merge the inventory records of two newly acquired stores. Although
BACKGROUND:You have been hired by the ACME Supply Corporation to write a program to merge the inventory records of two newly acquired stores. Although the inventory records of these two stores are very similar, they need a programmer toconflatethe two sets of files, remove any erroneous inventory records, and standardize the inventory measures.
TASK:Write a program to merge the two inventory files. The format of the inventory files is described below. Each unique item of inventory has been assigned a uniqueSKUnumber. This SKU number is a self-checking number consisting of a base number and a modulus-10 check-digit suffix. Both files are sorted in SKU number order and the resulting merged file must be in proper order. Note that some inventory items have incorrect SKU numbers (i.e., the self-check fails on these numbers), these items shouldnotbe placed in the merged file but should be sent to a reject file, as described below. Note also that if the identical SKU item appears inbothinput files, then the item amounts should be suitably combined and reported as one inventory record.
COMPLICATIONS:The inventory measures are not uniformly consistent. Some inventory items have amounts expressed inimperial(akaenglish;akaU.S. Customary Measure) units. The company needs all inventory measures to be inmetricunits. Thus if an inventory amount is expressed as an imperial amount, it must be converted to the equivalent metric amount in the merged file. The units of measure (expressed as character codes) that are within the files are:
I Square Inches C Square Centimeters P Pounds (avoirdupois) K Kilos F Feet M Meters E Each
INPUT/OUTPUT:The format forboththe input and the output files is:
Positions Description 01-09 SKU Number (right-justified) 10-18 Amount (xxxxxxx.x) 19-19 Blank 20-20 Unit of Measure (see above) NOTE: The amount should have one decimal place. Round as necessary.
REJECT FILE:Any inventory records that have invalid inventory numbers are written to the reject file. Donotconvert units of measure nor attempt to merge them; these records should look exactly like they did on input.
IMPLEMENTATION NOTES:For the completed version of this program, use as your source file name "consolidate.py". A starter skeleton program, is available as$PUB/consolidatestart.py. Be sure the first function in your source file ismain()and list the remaining functions in hierarchical order (as discussed when we reviewed hierarchy charts).Do not use any global variables.The input files will be "store1.dat" and "store2.dat"; you will need to make a (virtual) copy of these files in your directory. To make these virtual copies (i.e.,symbolic links), use the commands $ln -s $PUB/store1.dat store1.dat $ln -s $PUB/store2.dat store2.dat The merged output file must be named "merged.dat". The reject output file must be named "reject.dat".
INSPIRATION:Pattern your conflation logic after the example$PUB/conflate.pywe developed in class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started