Skip to main content

A package for easily accessing Toronto Open Data

Project description

TorontoOpenData Python Package

Overview

The TorontoOpenData package provides a Python interface to interact with the Toronto Open Data portal. It allows users to list, search, and download datasets, as well as load specific resources.

Installation

To install the package, run:

pip install toronto-open-data

Dependencies

  • pandas
  • wget
  • tqdm
  • ckanapi

Usage

Initialization

Initialize the TorontoOpenData class:

from TorontoOpenData import TorontoOpenData
tod = TorontoOpenData(api_key='your_api_key_here') # API key is optional

List All Datasets

List all available datasets:

datasets = tod.list_all_datasets()

Search Datasets

Search datasets by keyword:

search_results = tod.search_datasets('parks')

Download Dataset

Download a specific dataset:

tod.download_dataset('dataset_name')

Load Dataset

Load a specific file from a dataset:

file_path = tod.load('dataset_name', 'file_name.csv', smart_return=False)

Load a specific file, returning an object if supported (default behaviour):

file_object = tod.load('dataset_name', 'file_name.csv', smart_return=True)

Methods

  • list_all_datasets(as_frame=True): List all datasets.
  • search_datasets(query, as_frame=True): Search datasets by keyword.
  • search_resources_by_name(name, as_frame=True): Get dataset by name.
  • download_dataset(name, file_path='./cache/', overwrite=False): Download resource.
  • load(name, filename, file_path='./cache/', reload=False, smart_return=True): Load a file from the dataset.

Smart Return File Types

The package supports smart return for the following file types:

  • csv
  • docx
  • gpkg
  • geojson
  • jpeg
  • json
  • kml
  • pdf
  • sav
  • shp
  • txt
  • xlsm
  • xlsx
  • xml
  • xsd

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toronto_open_data-0.1.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toronto_open_data-0.1.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file toronto_open_data-0.1.2.tar.gz.

File metadata

  • Download URL: toronto_open_data-0.1.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for toronto_open_data-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8847bf4e009c907a111b5244cc904612e7f81b586bcb2510e5c674d3b7fe8e3b
MD5 d7e964d8521ad9d2ba874ab3db44ee1b
BLAKE2b-256 f960aeac5b0a20944f741c5201baddcd6ce00a25404b3c6fa8d30a6a9af4a048

See more details on using hashes here.

File details

Details for the file toronto_open_data-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for toronto_open_data-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dbd4a120c345c16122be264025fcb25db7a3da7ed2f9a98c32ab168576c81829
MD5 2b2599d1bbb3974b9aa550c1399820a3
BLAKE2b-256 c381a26bc46de465b0fddb39c41106f8f7331051247704f360111a9c3784f189

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page