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:

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.3.tar.gz (11.4 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.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toronto_open_data-0.1.3.tar.gz
  • Upload date:
  • Size: 11.4 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.3.tar.gz
Algorithm Hash digest
SHA256 ea35b8a0e2535fd0f18834871207bc5f9fab7d5eab860d47db2d3290b46b596f
MD5 a4b344c821baf2a41d7536679d29786b
BLAKE2b-256 26985277c586dd2896507e1821732d954544dd5fbcdc04097466f88a89e7aefc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toronto_open_data-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e6b095a5b4903821cd43f23eb27ddda1bd818129f65d0a7fe57aa3df7505b00f
MD5 8fc55f3e128dc419fe75e12b8c5eea93
BLAKE2b-256 c79cce6e2c00148a5b3f1b324972598e07c1f362e0ed8326ecec238c6144adbf

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