Git Product home page Git Product logo

e1006-project-3's Introduction

e1006-project-3

Farmers Market Database (100 pts)

Download the file markets.txt downloadwhich contains geographic information for over 7000 farmers markets in the US (source http://explore.data.gov/d/wfna-38ey). Each line contains information about one farmers market. Data fields are separated by a single "#" symbol. The fields are (in this order): state, market name, street address, city, zip code, longitude, latitude.

Your task is to write a tool that lets users search for farmers markets in their town or zip code. Download and complete the skeleton file project3.py download

a) Write the function read_markets(filename) that, given a filename, opens the file in the format described and reads in the data. Each farmers market should be represented as a tuple of 5 strings. You should ignore the longitude and latitude entries. The function should return two objects (i.e. a tuple of length 2):

  1. A dictionary mapping zip codes (keys) to lists of farmers market tuples (values)
  2. A dictionary mapping towns (keys) to sets of zip codes (values). Think about why it makes sense to use a set of zip codes instead of a list. b) Write a function print_market(market) that takes a farmers market tuple as its parameter and returns a human-readable string. Use string formatting to return the string. Despite the name, this function should not print the information. Just return a formatted string. Here is an example:

Columbia University Greenmarket E. Side of Broadway between 114th & 115th Streets New York, New York 10027

c) Write the main program that first reads in the markets.txt once (using the function from part (a)), and then asks the user repeatedly to enter a zip code or a town name (in a while loop until the user types β€œquit”). For each request, the program should print all farmers markets for this town or zip code (using the function from part (b)). If town names are ambiguous (because the town name exists in multiple US states), all entries should be printed. If a zip code or town name does not exist, the program should print "Not found." Hints:
You need to verify if the user input is a zip code (i.e. contains only numbers). If so, simply print all farmers markets in that zip code. If the user typed in the name of a town, loop over all zip codes for this town name and then use a nested loop to print all farmers markets for each zip code. The data set is messy -- there are entries with missing zip codes and other missing information. You can mostly ignore these for the purpose of the assignment. Your program should still work for entries that are correctly formatted in the file.

e1006-project-3's People

Contributors

noahlove avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.