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.1.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.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toronto_open_data-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 df0e81508aa73d6985df5746001872d691b022b24c42ece0db27dafc24da38a6
MD5 5d54aa7ce6981be3b4e8e03d5e5619f6
BLAKE2b-256 30bbaa4a5622b5f377c9a7249515d1ce4aa0989a00f9cb7d141f9fa03f9484fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toronto_open_data-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9cd1682e7182e90799cac31c56342d27cc32668a89608676ad9993a970c85288
MD5 776d9af337692b58fd99f04974ffab28
BLAKE2b-256 9f9dfd040a28d3ab7e6c5e8276caa94e74f6d8b9889eb756a659f1c828ce024f

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