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

Uploaded Python 3

File details

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

File metadata

  • Download URL: toronto_open_data-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 c2aea802c63de0875fddcadc7b6167090ebf3b4c2261709de55983c968bcfd32
MD5 428eef67632babc571ddb8e0fe90e311
BLAKE2b-256 71e48e98e0274de3b7e3d820ea4f7dc34d2a8ef0e9dec0fe6e2483a164bd785b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toronto_open_data-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b738e56edaf725ae0577eb07096544aa9da7f92dcd6ae31d6b85978b7ef421b2
MD5 c390905da70ea8cd9894d0be8cb939ce
BLAKE2b-256 b29db57814d9ab061b44340012f14646e5748e989f651390452b217e649ed0c8

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