Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python a small car dealership. An earlier failed attempt to hack together some computer-based parts inventory data has left some messy files that Angie wants

Python

a small car dealership. An earlier failed attempt to hack together some computer-based parts inventory data has left some messy files that Angie wants you to clean up. In preparation for that, youll need to break apart the unwieldy strings and clean up some errors that exist in the data.

User Interface2.1InputSince we dont yet know about files, well just paste in sample strings representing inventory data: Enter inventory string: This is a good sample to get you started(hint: this is not all the test cases you will need):*PART*DRPNO432DriverDoorPanel *2*Shop 1*$1,012.84*1,499.99*Chevy*Camaro*2011-2013*2.2OutputThe program breaks up the data into fields (separate kinds or columns of data), fixes up data as shown below and displays the field data. The sample above would yield this output:Type: PartPart#: DRPN0432Desc: Driver Door PanelQty: 2Loc: Shop1Cost: 1012.84Price: 1499.99Make: ChevyModel: CamaroYear Start: 2011Year End: 2013

in general, fields are demarcated by asterisks, though in a few cases well want a further breakdown. The first field represents the type of data; at present, Angie has only Part data.

Field SpecificsHere are further details on each field: FieldDescriptionIssues to FixTypeType of data this string represents. Currently, these are all PART The data is in all caps; Angie wants this proper cased, with only the first letter capitalizedPart#Angies part number for the item, consisting of four alphabetic characters followed by four numeric characters to fields are crammed into one. The Part Number is the first eight characters. There was bad data entry on these, with some Os where there should be zeroes; fix thoseDescriptionDescription of the item second field thats crammed; everything after the initial eight characters is Description. Some of this data has leading or trailing spaces that need to be removed. Also, no spaces were used, which needs to be fixed; each capital letter needs to be preceded by a space, e.g., HelloWorld becomes Hello WorldQuantity*Quantity on hand turn this into a number in case we need to do the math on it laterLocationWhere the item has located any spaces in this data need to be deleted, so Shelf 1 becomes Shelf1Cost*Angies cost for the item some of these have leading dollar signs; these need to be deleted. Some have embedded commas; we need those gone as well. Turn this into a number.Price*Angies selling price same as CostMakeMake of the car the part is for(no known issues at this point)ModelModel of the car the part is for(no known issues at this point)Year Start*Starting model year the part is forTwo fields are crammed into one; the data has a four-digit starting year, a hyphen, then a four-digit ending year; these need to be separated out and turned into numbers for computation purposesYear End*Ending model year the part is the second field thats crammed; read Year Start issues

HintsThere are some fields that require no fixing, at least not at this point. For consistencys sake and because we could learn new requirements for these fields later, create a fixed function for each field anyway.Write pseudocode so you can get clear on what needs to be done to each field. Pseudocode can often turn into useful code comments; you can start your internal documentation that way.There are cases where youll need to make several transformations on one field. Think about how to do this one step at a time. You can continue to modify the data as you go along.There are a bunch of string functions and methods you can choose from. My solution used these (though yours might find other clever ways):.is upper, .lower, .replace, .split, .strip, .upper, concatenation (using +), conversion of strings to integers and floats, and slicing.

Create a PyUnittest script called TestInvFixup.py. In it, create an automated test case for each of the fix-up functions. Each test case might require multiple assert statements as youll want to make sure the function works properly in multiple scenarios. Use the materials in the Canvas Resource module (at the top), including the Introduction to Software Testing document, and the two linked videos that demonstrate how to construct automated tests.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago