# fetch current version
<- readLines(url("https://raw.githubusercontent.com/StatePol/Database/main/VERSION"))[1]
database_version
# download data
<-
politician read.csv(paste0("https://raw.githubusercontent.com/StatePol/Database/main/_data/database", "/politician_", database_version, ".csv"))
<-
mandate read.csv(paste0("https://raw.githubusercontent.com/StatePol/Database/main/_data/database", "/mandate_", database_version, ".csv"))
<-
ppg read.csv(paste0("https://raw.githubusercontent.com/StatePol/Database/main/_data/database", "/ppg_", database_version, ".csv"))
<-
pggleadership read.csv(paste0("https://raw.githubusercontent.com/StatePol/Database/main/_data/database", "/ppgleadership_", database_version, ".csv"))
<-
presidency read.csv(paste0("https://raw.githubusercontent.com/StatePol/Database/main/_data/database", "/presidency_", database_version, ".csv"))
<-
committee read.csv(paste0("https://raw.githubusercontent.com/StatePol/Database/main/_data/database", "/committee_", database_version, ".csv"))
<-
cabinet read.csv(paste0("https://raw.githubusercontent.com/StatePol/Database/main/_data/database", "/cabinet_", database_version, ".csv"))
Download
CSV Files
R
To download the data in R, you can use the read.csv
function from the base R library.
Python
To download the data in Python, you can use the code provided below.
import requests
import pandas as pd
# fetch current version
= "https://raw.githubusercontent.com/StatePol/Database/main/VERSION"
version_url = requests.get(version_url).text.strip()
database_version
# construct base URL
= "https://raw.githubusercontent.com/StatePol/Database/main/_data/database"
base_url
# download function
def download_csv(file_name):
= f"{base_url}/{file_name}_{database_version}.csv"
csv_url = pd.read_csv(csv_url)
df return df
# download data
= download_csv("politician")
politician = download_csv("mandate")
mandate = download_csv("ppg")
ppg = download_csv("ppgleadership")
pgg_leadership = download_csv("presidency")
presidency = download_csv("committee")
committee = download_csv("cabinet")
cabinet
# check data
politician.head()
Checking the Database Version and Changelog
To ensure you are using the correct version of the StatePol database, please check the VERSION file in our repository for the current version number.
We recommend reviewing the CHANGELOG to be aware of the changes, additions, or fixes in each version of the database.