Menu

(Solved) : Please Don T Copy Past Answer Form Previous Question Asked Problem Data Processing Owners Q43990826 . . .

Please don’t copy and past the answer form a previous questionthat was asked.

Problem: Data Processing

The owners of a corner store do an inventory of what items theyhave on their shelves after they close their store every day. Theyhave asked you to create a Python program that uses this inventoryinformation to generate a daily report of what needs to be orderedfrom their suppliers. The store owners will order more of aparticular product when there are less than 20 of those items lefton their shelves. When they order a product, they order enough tostock a total of 50 of those items on their shelves. For example,if they have 18 bags of Salt & Vinegar chips at the end of theday, they order 50-18 = 32 new bags. They may have many suppliersthat offer the same product, so they must choose the supplier thatoffers the product at the lowest price. If all suppliers offer theproduct at the same price, any supplier can be selected.

Your Python program will use input data from the following fourfiles:

The first file, products.txt, contains the listof all products sold in the store. Each line contains informationabout a single product: the product code, followed by a semicolon(;), followed by the product name. For example, the contents ofthis file could be this:

123456789;2L 2% Vitali Milk

123456798;1L 2% Vitali Milk

456392452;70% Cocoa Zimbra Chocolate

456123490;Zimbra Milk Chocolate

634590221;Onion flavour chips

634599011;Vinegar flavour chips

780123678;Sliced white bread

780432109;Sliced whole wheat bread

809001234;2L Orange Juice

808765432;2L Apple Juice

The second file, suppliers.txt, contains information about the suppliers. Each line contains the phone number, the supplier name, and the supplier’s address, all separated by “;”. The phone number is unique and can be used as an ID. For example, the contents of this file could be this:

7808907654;Wholesale club;56 Stony Place

7801234567;Costcorner;36 Spruce Street

7807890123;PriceCo;98 Alberta Avenue

7804922860;Lows Lili;66 Hinton Road

7809876543;Coast to coast;34 Sherwood park Avenue

7801236789;Always Supplies;101 Edson Crest

7804321098;O and Z company;32 Alphonse Street

The third file, availability.txt, containsinformation about what product the suppliers have and at whatprice. Each line contains a product code, a supplier’s phonenumber, and the price. These 3 fields are separated by a “,”.Notice that the same product may be available from multiplesuppliers, but at different prices. Here is an example:

123456789,7807890123,2.58

123456789,7804922860,2.99

The last file, onshelves.txt, contains theinventory for that day. Its structure is simple. Each line has aproduct code followed by the number of items left on the shelves,where the two fields are separated by “#”. For example:

123456789#3

123456798#9

456392452#23

456123490#14

634590221#18

634599011#15

780123678#1

780432109#5

809001234#48

808765432#28

For all four input files, you can assume that there will not bewhitespace at the beginning of each line, nor will there be blanklines in the file. You can also assume that all products stocked bythe store are present in availability.txt, but availability.txt maycontain items that are not stocked by the store.

Your Python program must generate a file,orders.txt, that contains a table listing all ofthe products that must be ordered from the suppliers. The tableshould be formatted as follows, with the products grouped bysupplier. In other words, the table should be sorted by thesupplier column, with the phone numbers listed in ascending order.No additional sorting needs to be performed on the table. Thesupplier with the highest cumulative cost for the current ordershould be printed below the table, as shown. If there is a tie forthe highest cumulative cost, all of those suppliers should bedisplayed.

+————–+——————+——–+—————-+———-+| Product code | Product Name |Quantity| Supplier | Cost |+————–+——————+——–+—————-+———-+| 123456789 |*2L 2% Vitali Mil | 47 | (780) 789 0123 | $ 121.26 | | 456123490 | Zimbra Milk Choc | 36 | (780) 789 0123 | $ 26.49 | …| 780432109 |*Sliced whole whe | 45 | (780) 998 9334 | $ 89.10 |+————–+——————+——–+—————-+———-+| Total Cost | $ 7292.32|+————–+—————————+Highest cost: Costcorner (780) 123 4567 [$234.05]Highest cost: O and Z company (780) 432 1098 [$234.05]The table has 5 columns:

  • The first column is the product code.
  • The second column is the product name truncated after the 16thcharacter. So the column has to be 18 characters wide. That is, Ifthe product name is longer than 16 characters, the name istruncated to fit. In addition, the name is prefixed with”*” if the number to order is higher than 40.
  • The third column is the number of items to order. This amountis never more than 50, but the column is 8 characters wide. Alignthe numbers to the right of the column, but leave a single spaceafter the number.
  • The fourth column is the supplier phone number. This number hasto be formatted as (999) 999 9999.
  • The last column is the cost. This is the number of items toorder multiplied by the price per item charged by the supplier. Thecost should be preceded by “$”. It is assumed this cost will neverreach $10000 and thus should be 4 positions before the decimalpoint and two positions after the decimal point.
  • Finally, a line at the end of the table should indicate thetotal amount that the whole order will cost, with room for 7 digitsbefore and 2 digits after the decimal point. The table should beformatted as illustrated above.

The line after the table provides information about the supplierwith whom the largest order is placed. The full name of thesupplier should be displayed, followed by a single space, followedby their formatted phone number, followed by a single space,followed by the cumulative cost for that supplier. The cumulativecost should be surrounded by square brackets, without anywhitespace surrounding the number and displayed with 2 decimalnumbers.

In addition to the output file, the same output should alsoappear on the screen.

Note that the example output table is not exactly related to theinput examples provided here. Indeed, the output depends on 4 inputfiles. The input and sample output provided here are just examplesto indicate the format of all of the files. You should create yourown files and stick to the structure described here. The TAs willevaluate your assignment with different input files.

Stick to what the customer has requested as format. Do not tryto make it “nicer” or “more practical”, or anything else. This iswhat the customer wants.

General Guidelines

In addition to making sure that your code runs properly, we willalso check that you follow good programming practices. For example,divide the problem into smaller sub-problems, and write functionsto solve those sub-problems so that each function has a singlepurpose; use the most appropriate data structures for youralgorithm; use concise but descriptive variable names; defineconstants instead of hardcoding literal values throughout yourcode; include meaningful comments to document your code, as well asdocstrings for all functions; and be sure to acknowledge anycollaborators/references in a header comment at the top of yourPython file.

Restrictions for this assignment: you cannotuse break/continue, and you cannot import any modules. Doing sowill result in deductions.

The data is already in proper format

Expert Answer


Answer to Please don’t copy and past the answer form a previous question that was asked. Problem: Data Processing The owners of a …

OR