Client for Swiss parliament API
Project description
swissparlpy
Inspired by the R package swissparl, this module provides easy access to the data of the OData webservice of the Swiss parliament.
Table of Contents
Installation
swissparlpy is available on PyPI, so to install it simply use:
$ pip install swissparlpy
Usage
See the examples
directory for more scripts.
Get tables and their variables
>>> import swissparlpy as spp
>>> spp.get_tables()[:5] # get first 5 tables
['MemberParty', 'Party', 'Person', 'PersonAddress', 'PersonCommunication']
>>> spp.get_variables('Party') # get variables of table `Party`
['ID', 'Language', 'PartyNumber', 'PartyName', 'StartDate', 'EndDate', 'Modified', 'PartyAbbreviation']
Get data of a table
>>> import swissparlpy as spp
>>> data = spp.get_data('Canton', Language='DE')
>>> data
<swissparlpy.client.SwissParlResponse object at 0x7f8e38baa610>
>>> data.count
26
>>> data[0]
{'ID': 2, 'Language': 'DE', 'CantonNumber': 2, 'CantonName': 'Bern', 'CantonAbbreviation': 'BE'}
>>> [d['CantonName'] for d in data]
['Bern', 'Neuenburg', 'Genf', 'Wallis', 'Uri', 'Schaffhausen', 'Jura', 'Basel-Stadt', 'St. Gallen', 'Obwalden', 'Appenzell A.-Rh.', 'Solothurn', 'Waadt', 'Zug', 'Aargau', 'Basel-Landschaft', 'Luzern', 'Thurgau', 'Freiburg', 'Appenzell I.-Rh.', 'Schwyz', 'Graubünden', 'Glarus', 'Tessin', 'Zürich', 'Nidwalden']
Release
To create a new release, follow these steps (please respect Semantic Versioning):
- Adapt the version number in
swissparlpy/__init__.py
- Update the CHANGELOG with the version
- Create a pull request to merge
develop
intomain
(make sure the tests pass!) - Create a new release/tag on GitHub (on the main branch)
- The publication on PyPI happens via GitHub Actions on every tagged commit
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
swissparlpy-0.1.1.tar.gz
(16.5 kB
view hashes)
Built Distribution
Close
Hashes for swissparlpy-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e98e4272cff9bb9d20855c0f0f77fea05be4c32bc2087cd277ec715917cf236a |
|
MD5 | 1568154ea59a349fff5eb57d59cc5dec |
|
BLAKE2b-256 | 4cc64f2194e1b60ed73ed8e49ef188263448b9b2edd6a4dda87975fb4a9e7fa5 |