Historical design reference, not a tested end-to-end program. Review the current skill before adapting templates. Source-writing and incomplete template behavior are described there. Historical examples and proposed supplementation are not implementation guarantees.
Yearbook Excel files are organized as:
<yearbook_root>/
中国工业统计年鉴2013(Excel)/
2分行业数据/ # Cat2 sector tables
规模以上工业企业主要经济指标*.xlsx
3分地区数据/ # Regional tables
按地区分组的<industry_name>主要经济指标.xlsx
中国工业统计年鉴2014(Excel)/
...
Each regional Excel contains one or more panels identified by a 地区 (region) header cell. Panels share the same structure: region/province names in one column, metric headers spanning one or more merged rows above the data.
| Pipeline | Entry Script | Input | Output |
|---|---|---|---|
| National sector | Adaptation example; dedicated template not implemented | National industry Excel tables | Output contract requires domain adaptation |
| Regional sector | templates/process_regional_sector.R | 3分地区数据/ Excel files |
economic_indicators/分地区规模以上工业企业主要经济指标{year_range}.csv |
| Product output | templates/process_product_output.R | Product Excel files + optional MEIC | physical_output/provincial_industrial_products_{year_range}_estimated.csv |
Yearbook Excel files use a 地区 cell as the panel anchor. Core algorithm:
1. Read entire Excel sheet as character matrix (no type inference)
2. Locate all "地区" cells → each defines a panel's position
3. For each panel:
a. Determine column span (next "地区" col → right boundary)
b. Determine row span (next "地区" row → bottom boundary)
c. Merge multi-row headers above data start
d. Filter rows against region whitelist
e. Convert metric columns to numeric with issue logging
其他采矿业 → code 1200)Keep only recognized 31 mainland China provinces + 全国:
region_names <- c(
"全国", "北京", "天津", "河北", "山西", "内蒙古", "辽宁", "吉林", "黑龙江",
"上海", "江苏", "浙江", "安徽", "福建", "江西", "山东", "河南", "湖北",
"湖南", "广东", "广西", "海南", "重庆", "四川", "贵州", "云南", "西藏",
"陕西", "甘肃", "青海", "宁夏", "新疆"
)
Normalize: 合计 and 总计 → 全国; remove all spaces and invisible characters.
Chinese text misread as GB18030 bytes is common in yearbook files. Detection: convert all column names via iconv(x, from=”GB18030”, to=”UTF-8”); if the output contains more valid Chinese characters than the original, apply the conversion globally.
Headers may span 2-3 rows. Merge logic:
单位亿元)The 2023 yearbook splits each industry into a main table and continuation tables. Pair them by matching numeric table IDs extracted from file names, then merge horizontally by province.
Exclude files whose names match organization-type keywords that are not industry classifications:
国有控股 | 有限责任公司 | 股份有限公司 | 私营 | 港澳台商 | 外商投资 | 大型 | 中型 | 小型
Convert cell text to numeric:
Product output data starts as wide tables (products as columns). Transform:
Year, province, 水泥(万吨), 粗钢(万吨), ...
→
Year, province, product_name, unit, output
Parse product name and unit from column headers via product_name(unit) pattern, compute unit coefficients (万 → 10000, 亿 → 100000000).
An adapted task should generate a local cleaning report with (not a guaranteed output of every bundled template):
Exclude tables organized by enterprise registration type rather than industry classification:
| Keyword | Meaning |
|---|---|
国有控股 |
State-controlled |
有限责任公司 |
Limited liability |
股份有限公司 |
Joint-stock |
私营 |
Private |
港澳台商 |
HK/Macau/Taiwan |
外商投资 |
Foreign-invested |
大型/中型/小型 |
Large/medium/small scale |
Query yearbook_regional_sector_template and yearbook_product_output_template with describe-tool to locate the actual R files. Both are disabled in run-tool; a dedicated national-sector template is not implemented. The examples and YAML below are adaptation material, not executable API payloads or auto-loaded configuration.
Read templates/config.yaml as a non-executable mapping example; inspect each template and apply its settings explicitly. Candidate fields include: