Skip to main content

A scraper of statistical data from socialstyrelsen.se built on top of Statscraper.

Project description


This is a scraper for statistical data from the statistcial databases http://www.socialstyrelsen.se built on top of the `Statscraper package <https://github.com/jplusplus/statscraper>`.

Very much alpha. Only tested on a selected topics.

Install
-------

pip install -r requirements.txt


Example usage
-------------

.. code:: python

from socialstyrelsen import SocialstyrelsenScraper

scraper = SocialstyrelsenScraper()
scraper.items # List databasese
# [<SocialstyrelsenDataset: abort (Aborter)>, <SocialstyrelsenDataset: amning (Amning)>...]

dataset = scraper.get("ekonomisktbistandmanad") # Get a specific (by id)

# Inpect dataset
print dataset.dimensions
# [<SocialstyrelsenDimension: MATT>, <SocialstyrelsenDimension: FOR>, <SocialstyrelsenDimension: LANGD>, <SocialstyrelsenDimension: OMR>, <SocialstyrelsenDimension: AGI>, <SocialstyrelsenDimension: AR>]

print dataset.dimensions["OMR"].allowed_values
# [<SocialstyrelsenDimensionValue: 0 (Hela Riket)>, <SocialstyrelsenDimensionValue: 1 (Stockholm)>, ...]

# Make a query, you have to explicitly define all dimension values you want
# to query.
res = dataset.fetch({
"TABELL": "1",
"OMR": ["01", "03"],
"MANAD": ["4", "5", "6"],
"AR": "2017",
"MATT": "1",
})

# Do something with the result
df = res.pandas


TODO
----

- Currently only properly tested on "ekonomiskt bistånd"
- Handle large queries.
- Handle dimension labels


Develop
------

Run tests:

make tests

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

socialstyrelsen_scraper-0.0.2.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file socialstyrelsen_scraper-0.0.2.tar.gz.

File metadata

File hashes

Hashes for socialstyrelsen_scraper-0.0.2.tar.gz
Algorithm Hash digest
SHA256 13154cc5a740869c4515bb4b1600d08449dd6c36a24ea3a5b6b79e8c2406e691
MD5 798eb17a715ac5dbeb60efb146800f80
BLAKE2b-256 815851c4bbc5e270bf311c4c5b728a6470a139c4c72290a00730899d181a8e41

See more details on using hashes here.

Supported by

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