Key Information

Register
Submit
The challenge is finished.

Challenge Overview

The challenge is to build a Python script that accepts some simple input values, connects to the WeatherUnderground API, and returns some cleaned, simplified values from the API’s results.

Input

  • - The main ‘import_data’ function in Python should accept the following parameters:

    • - zip_code

      • - Only for the USA. 5 digit zip code, e.g., 21202.

      • - No data validation necessary

    • - start_date

      • - Any date format is acceptable.

      • - datetime object seems reasonable.

      • - Does not need to support hourly or less resolution; only daily resolution.

    • - end_date

      • - Any date format is acceptable, so long as it matches the format of start_date.

      • - It must be larger than start_date.

Output

  • - The output of the import_data function should be:

    • - zip_code

    • - start_date

    • - end_date

    • - weather_observations

      • - a list of dict objects, which have the properties:

        • - date

          • - Any date format is acceptable, so long as it matches the format of start_date / end_date.

        • - weather_conditions

          • - a list of strings that indicate cloud coverage.

          • - these strings will indicate the weather conditions per hour of the day. it should be an ordered list of conditions.

Example output

{zip_code : <zip_code>,

start_date: <start_date>,

end_date : <end_date>,

"weather_observations":

[

{

   "date": "20151126",

   "weather_conditions": [

       "Mostly Cloudy",

       "Cloudy",

       "Cloudy",

       "Cloudy",

       "Overcast",

       "Overcast",

       "Overcast",

       "Overcast",

       "Overcast",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear"

   ]

},

{

   "date": "20151124",

   "weather_conditions": [

       "Mostly Cloudy",

       "Cloudy",

       "Cloudy",

       "Cloudy",

       "Overcast",

       "Overcast",

       "Overcast",

       "Overcast",

       "Overcast",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear"

   ]

}

,

{

   "date": "20151125",

   "weather_conditions": [

       "Mostly Cloudy",

       "Cloudy",

       "Cloudy",

       "Cloudy",

       "Overcast",

       "Overcast",

       "Overcast",

       "Overcast",

       "Overcast",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear",

       "Clear"

   ]

}

]

Wunderground API

The wunderground API is straightforward to use. Documentation is here: http://www.wunderground.com/weather/api/d/docs.

Create your own API key to use the API. Only 500 requests per day per key are allowed, so if you reach that limit, you can create another free API key here: http://www.wunderground.com/weather/api/

We will be using the “history” endpoint, documented here: http://www.wunderground.com/weather/api/d/docs?d=data/history&MR=1.

The request to this endpoint, given the inputs, is very easy to construct according to the format:

http://api.wunderground.com/api/$API_KEY/history_$DATE_IN_YYYYMMDD_FORMAT/q/$ZIPCODE.json

For instance, here’s a fully functioning example URL call:

http://api.wunderground.com/api/9cfcefad7ac10e20/history_20060405/q/21202.json

Only one date (day) can be retrieved per call. So the python method will need to make one API request per date that is accessed. If the function receives a date range of 3 dates, it will make 3 separate calls.

Out of the returned data, we would like to extract the field history.observations.conds, and take each observation from each hour and collapse them into an ordered list according to the output specified above.

Sample Usage

The script will be integrated with a django application so you need to show a sample usage of the script.

Technology

Python version 3.x running on Ubuntu

Coding Standard

Follow python coding best practices : PEP 8 for the main text, and PEP 257 for docstring conventions

Documentation

Your solution must be well documented.

Configuration

All sensitive data should be configurable.

Readme

Provide a detailed readme file using Markdown language with following information :

- Overview

- Configurations

- Setup Prerequisites

- Usage Example

Deliverable

- Source code that implemented the requirements

- README file



Final Submission Guidelines

.

ELIGIBLE EVENTS:

2016 TopCoder(R) Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30052297