CS3723 Pgm 5 Python (20 pts)
Question # 40033 | Programming | 6 years ago |
---|
$20 |
---|
CS3723 Pgm 5 Python (20 pts)
Business Problem:
You have been tasked by a business to match customer addresses in preparation for an address change. Due to the business using many purchased software packages, the same address might be stored in multiple databases. The different systems store addresses differently (number of lines and size of a line). Some of the systems have zip+4 (10 characters including the dash); whereas, others just have 4 digits.
In program 5, you will read data from a file that contains command text lines and show the addresses in a readable style. In program 6, you will classify the parts of an address and then match the addresses for a customer.
Input Data will be text lines in the form of commands:
CUSTOMER customerName
ADDRBEGIN
LINE streetLine1
... (possibly multiple LINE commands for an address)
CITY city
STATE stateCD
ZIP zipCode (might be zip+4)
ADDREND
... (possibly multiple ADDRBEGIN ... ADDREND combinations for a customer)
CUSTOMEREND
Sample Data:
CUSTOMER BOB WIRE
ADDRBEG
LINE 123 DIRT
LINE RD
CITY SAN ANTONIO
STATE TX
ZIP 78210
ADDREND
ADDRBEG
LINE 123 DIRT
CITY SAN ANTONIO
STATE TX
ZIP 78210
ADDREND
ADDRBEG
LINE 123 DIRT LN
CITY SAN ANTONIO
STATE TX
ZIP 78210
ADDREND
CUSTOMEREND
CUSTOMER PENNY LOAFER
ADDRBEG
LINE 111 SHOE LN
CITY SAN ANTONIO
STATE TX
ZIP 78249-1234
ADDREND
ADDRBEG
LINE 111 SHOE ST
CITY SAN ANTONIO
STATE TX
ZIP 78249-1234
ADDREND
ADDRBEG
LINE 111 BOOT ST SOUTH
LINE APT #5A
CITY SAN ANTONIO
STATE TX
ZIP 78230
ADDREND
ADDRBEG
LINE 111 S BOOT STREET NR 5A
CITY SAN ANTONIO
STATE TX
ZIP 78230
ADDREND
CUSTOMEREND
CUSTOMER FLO N WATER
ADDRBEG
LINE 45 S.W. VISTA RIO GRANDE RD
CITY SAN ANTONIO
STATE TX
ZIP 78210
ADDREND
ADDRBEG
LINE 45 S WEST VISTA RIO GRANDE RD
CITY SAN ANTONIO
STATE TX
ZIP 78210
ADDREND
ADDRBEG
LINE 45 SOUTHWEST VISTA RIO
LINE GRANDE ROAD
CITY SAN ANTONOI
STATE TX
ZIP 78210
ADDREND
CUSTOMEREND
Reading the Data
Due to the business' potential to have millions of customers and many more addresses, it isn't feasible to use Python's capabilities to read all the data into memory at once. Instead, you must read individual textlines using input().
There may be multiple street address lines ("LINE" commands) for an address. Concatenate them together with a space between the lines.
You may assume all data is uppercase.
Output (see sample below)
For each customer:
Show the customer's name
Show each address with a sequence number for identification purposes.
Coding Requirements
Your program must be separated into multiple functions and source files. The main driver should be in one .py file and the information for reading and printing addresses must be in a separate .py file. To import code from another file, use a Python statement like this:
from fileName import funcName1, funcName2
Note the actual file would be named fileName.py. Inotherwords, the filename specified on the from would be without the .py.
To make program 6 easier, I recommend placing the parts of an address in a dictionary with keys like "STREET", "CITY", "STATE", and "ZIP".
Your main driver must have documentation describing purpose, input, and output.
Your .py file for addresses must have documentation for each function describing its purpose, parameters, and returns. Please document the purpose of each conditional statement.
Sample Output
BOB WIRE
1 123 DIRT RD
SAN ANTONIO, TX 78210
2 123 DIRT
SAN ANTONIO, TX 78210
3 123 DIRT LN
SAN ANTONIO, TX 78210
PENNY LOAFER
1 111 SHOE LN
SAN ANTONIO, TX 78249-1234
2 111 SHOE ST
SAN ANTONIO, TX 78249-1234
3 111 BOOT ST SOUTH APT #5A
SAN ANTONIO, TX 78230
4 111 S BOOT STREET NR 5A
SAN ANTONIO, TX 78230
FLO N WATER
1 45 S.W. VISTA RIO GRANDE RD
SAN ANTONIO, TX 78210
2 45 S WEST VISTA RIO GRANDE RD
SAN ANTONIO, TX 78210
3 45 SOUTHWEST VISTA RIO GRANDE ROAD
SAN ANTONOI, TX 78210