An interactive Shiny for Python web app for browsing and analyzing China's national climate policy targets — developed by the Macro and Green Finance Lab at Peking University (MGF@PKU).
This tool is designed as a template for research, presentation, and educational purposes. It is not intended for local hosting by the general public — instead, it showcases how one might integrate real-time GitHub-hosted datasets into a Shiny app.
This app visualizes a curated dataset of China's national climate policy targets across sectors such as GHG Emissions, Energy/Power, Buildings, Transport, LULUCF, Circular Economy, Pollution, and Finance. Features include:
- 🔎 Filtering by target horizon, target category, and keyword
- 🧾 Paginated table view with clickable rows
- 📥 Export of filtered or full results (XLSX, sent by email)
Powered by:
shinyfor interactivitypolarsfor fast data wrangling- GitHub API for real-time data retrieval
- Custom CSS + JS enhancements
- Paginated and stylized data table
- Filter by target horizon, target category, and keyword
- XLSX export of current filtered or full results (sent via email)
- Integrated GitHub data sync (fetches latest release from
MGFPKU/target_dataset) - Bilingual UI (Chinese / English, controlled by
LANGUAGEenv var) - Modern UI with iconography, tooltips, and layout styling
This app uses GitHub as a remote data backend. If you're customizing or extending the app:
git clone https://github.com/MGFPKU/target_table.git
cd target_tableWe use uv for fast dependency resolution:
uv sync
⚠️ We do not publish a GitHub token in this repo. If you need access for development or testing, contact the maintainers for a personal access token (PAT) with read-only access to the dataset repository.
You'll need to set the token in a .env file like:
GITHUB_TOKEN=ghp_...
GOOGLE_SCRIPT_URL=https://script.google.com/macros/s/...
LANGUAGE=ENBelow is what each variable does:
GITHUB_TOKEN: a GitHub Personal Access Token (PAT) with read access to theMGFPKU/target_datasetrepository. The app uses this token to downloaddataset.xlsxfrom the latest release. Keep this token private (do not commit it).GOOGLE_SCRIPT_URL: the public URL for a Google Apps Script web app that acts as the mailing bot. The Shiny app POSTs filtered exports (XLSX) to this endpoint and the script forwards them by email.LANGUAGE: set the UI language for the app. UseENfor English orCNfor Chinese. The value controls which translations are displayed in the interface.
python -m shiny run --reload app.pyThen open your browser to:
http://localhost:8000Or more conveniently, install the shiny extension to Positron/VS Code and press the Run button.
The repository layout and purpose of key files:
.env # Environment variables (not committed, create locally following setup instructions)
app.py # Main Shiny app (UI + server)
table.py # Paginated table output and helpers
download.py # Download UI and mailing helpers (POSTs to Google Script)
data.py # Data fetching and processing logic
i18n.py # Translation helper; reads LANGUAGE to switch UI
translation.json # Translation strings used by `i18n.py`
sheets.json # Sheet names and source sheet config for dataset.xlsx
pyproject.toml # Project metadata / build config (managed by uv)
.python-version # Python version pinning for uv
requirements.txt # Dependency pins (optional with pyproject)
LICENSE # License
README.md # Project documentation (this file)
.gitignore # Git ignore rules
Notes:
- Edit
app.pyto change high-level UI or filtering logic. table.pycontrols how target rows are rendered.data.pyhandles fetching and parsingdataset.xlsxfrom the latest GitHub release.download.pyintegrates with the Google Apps Script mailing bot (set viaGOOGLE_SCRIPT_URL).
If you use the MGF dataset in your research or writing, please cite us as follows:
Macro and Green Finance Lab, Peking University (MGF@PKU)
"China's National Climate Targets Database"
https://mgflab.nsd.pku.edu.cn/MGFsjk/zczz/index.htm, 2025.
The dataset is hosted in a private GitHub repository (MGFPKU/target_dataset) along with our data collection scripts. We apologize for the inconvenience. But the dataset provided through the app is updated in real-time and contains most information available on the original source.
Developed by Dianyi Yang (@kv9898) for the Macro and Green Finance Lab at Peking University (MGF@PKU).
If you use or adapt this project for academic or institutional purposes, please cite the dataset accordingly and feel free to reach out for collaboration or inquiries.