AutomateTheBoringStuff.Ch14 package

Submodules

AutomateTheBoringStuff.Ch14.P1_readCSV module

Read CSV

This program uses csv to read .csv files.

Note

Uses provided example.csv file.

AutomateTheBoringStuff.Ch14.P1_readCSV.main()[source]

AutomateTheBoringStuff.Ch14.P2_writeCSV module

Write CSV

This program uses csv to write .csv files.

Note

Creates ‘output.csv’ and ‘example.tsv’ files.

AutomateTheBoringStuff.Ch14.P2_writeCSV.main()[source]

AutomateTheBoringStuff.Ch14.P3_removeCsvHeader module

Remove CSV header

Removes the header from all CSV files in the current working directory.

Note

Outputs to ./headerRemoved directory.

AutomateTheBoringStuff.Ch14.P3_removeCsvHeader.main()[source]

AutomateTheBoringStuff.Ch14.P4_readWriteJSON module

Read/write JSON

This program uses json to manipulate JSON data.

AutomateTheBoringStuff.Ch14.P4_readWriteJSON.main()[source]

AutomateTheBoringStuff.Ch14.P5_quickWeather module

Quick weather

Prints 3-day weather information for a location specified in the command line.

AutomateTheBoringStuff.Ch14.P5_quickWeather.getWeather(loc: str, apikey: str) → dict[source]

Get weather

Uses OpenWeatherMap.org API to get JSON data of given location with given API key. Data is stored as a dict and the current date and time (in UTC) is also stored using datetime.datetime.now().

Parameters:
  • loc – Location to get weather data of in City,Country Code format.
  • apikey – API key used to interface with OpenWeatherMap.org’s API.
Returns:

Dictionary with weather JSON data and current date time (in UTC) added.

AutomateTheBoringStuff.Ch14.P5_quickWeather.main() → None[source]

P5_quickWeather.py

Displays given location’s 3-day weather information.

Returns:None. Weather data is printed to terminal and JSON data is stored in a shelve shelf, weather.

Note

To prevent excessive API requests, JSON data is stored in a shelve shelf and only redownloaded every 10 minutes. Time is kept track using datetime.datetime.now() and datetime.timedelta.

Module contents