Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

PROGRAM DESCRIPTION:
In this assignment, you will write a Python program to process an input file.

Download the file minor5.tsv. Each row of this file contains a data record separated by a single
tab. The fields are: state, street address, city, zip code.
Your need to write a python program that allows users to search for entries using the city
or zip code.

(a) Write a python function called load_records that given a filename as input, opens the file
and reads in the data. Each data record should be represented as a tuple of strings. The
function should return two objects: A dictionary mapping zip codes to lists of such tuples
and a dictionary mapping cities to sets of zip codes.
(b) Write a python program that first reads in the data file once (using the function from part
(a)), and then asks the user repeatedly to enter a zip code or a city name (in a while loop
until the user types “quit”). For each request, the program prints all data records for this
city or zip code. If city names are ambiguous (duplicated city names), all entries should be
printed. If no records can be found, you need to print according information such as :
No records found in this town.
or
No records found in this zip code.
(c) The format for printed out information should be:
Street address
Town, state, zipcode

minor5.tsv

Arkansas

705 E. Union Ave

Wynne

72396

California

Main Street

Redding

96099

California

Calabasas & Mullholland Drive

Tarzana

91356

Colorado

Buffalo Street

Dillon

80435

Colorado

802 W. Drake Rd

Fort Collins

80526

New Mexico

6th & University

Las Vegas

98765

New Mexico

corner of bookout and central avenue

tularosa

88352

New York

112th Madison Avenue

NY

10029

New York

W. 57th St. & Ninth Ave at Balsley Park

NY

10037


SAMPLE OUTPUT:

hz0099@cse02:~/3600/python$ python minor5.py
Enter input:10037
W. 57th St. & Ninth Ave at Balsley Park
NY, New York, 10037
Enter input:88352
corner of bookout and central avenue
tularosa, New Mexico, 88352
Enter input:Wynne
705 E. Union Ave

Wynne, Arkansas, 72396
Enter input:Fort Collins
802 W. Drake Rd
Fort Collins, Colorado, 80526
Enter input:denton
No records found in this town.
Enter input:76207
No records found in this zip code.
Enter input:NY
W. 57th St. & Ninth Ave at Balsley Park
NY, New York, 10037
112th Madison Avenue
NY, New York, 10029
Enter input:quit
hz0099@cse02:~/3600/python$

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education