By Gianluca Campanella (gianluca@campanella.org)
The Italian National Institute of Statistics (Istat) collates demographic data from register offices, and makes them available through its demographics portal.
This repository contains a set of scripts to scrape and aggregate monthly time series of births, deaths, and net migration at municipality (comune) level, separately for men and women.
The data are made available under a Creative Commons Attribution 4.0 International (CC BY 4.0) licence, like the original data.
- Run the Scrapy script
scrape.py
:scrapy runspider -o istat-demographics-scraped.csv -t csv scrape.py
- Run the R script
postprocess.R
:This will produce the output fileR --vanilla < postprocess.R
istat-demographics.csv.gz
- Optionally, delete the file
istat-demographics-scraped.csv
The file istat-demographics.csv.gz
contains the following variables:
Name | Content |
---|---|
group |
NUTS 1 (group of regions) identifier |
region |
NUTS 2 (region) identifier |
province |
NUTS 3 / LAU 1 (province) identifier |
municipality |
LAU 2 (municipality) identifier |
year |
Year |
month |
Month (1 = January, 12 = December) |
sex |
Sex (M = Male, F = Female) |
births |
Births |
deaths |
Deaths |
net_migration |
Net migration |
Note: LAU identifiers are updated periodically; see this page (in Italian) for more details.