查明学费不缺且给出0856定向缺口清单
官方目录 chsi_2027_dir.tuition_fee 已覆盖80565行543校,口径是元/年: 学硕3学制均值8061元(若为全程应≈24000),与启航按校+专业码对齐1325例 1009例全等。原计划去外部站采学费是方向错——在职研源只覆盖非全, 而全日制年费库里早已有官方值。只把5539个NULL行填上,已有值不动, 差异316例里仅26例是年费与全程混用,其余按口径冲突留证。 0856定向清单:362所开0856的院校里347所缺2027推免接收数、 只有18所有2027自命题大纲、2所有逐专业线,这三项才是该优先补的。
This commit is contained in:
1 parent
d24325ba06
commit
16f8a60bb6
5 files changed
+3908
No files matched your search
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"结论": "学费不缺。官方研招网目录 chsi_2027_dir.tuition_fee 已覆盖 80,565 行 / 543 校,口径是元/年。",
|
||||||
|
"口径证据": [
|
||||||
|
"学硕全日制且学制3年的平均学费 8061 元;若为全程应≈24000 元(国家标准学硕 8000 元/年)",
|
||||||
|
"与启航 qihang_tuition 按「校+专业码」对齐 1,325 例,1,009 例完全相等(76.2%),且相等值都落在 8000/10000/12000 这类年费档位",
|
||||||
|
"启航自身有 460 行单位「未标注」,占其总量 22%,口径不清的一方是平台不是官方"
|
||||||
|
],
|
||||||
|
"差异归因": "316 例差异里只有 26 例是 2 倍关系(年费 vs 全程混用),其余 290 例是数值本身不同,按口径冲突单列,不判谁错,也不覆盖点对点的已有值",
|
||||||
|
"回填动作": "只把 5,539 个 tuition_year 为 NULL 的点对点行填上官方值,已有值一律不动;全程额按 学制×年费 折算并标 derived",
|
||||||
|
"对采集方向的修正": "原计划派 agent 去外部站采学费是方向性错误——在职研类源只覆盖非全,而库里官方源已有全日制年费。外部源的真实增量只剩「住宿」这一新字段与非全的高额学费交叉核验",
|
||||||
|
"0856定向缺口": {
|
||||||
|
"开0856校": "362 所 / 1880 行(含学院)",
|
||||||
|
"缺2027推免接收数": "347 校 / 1775 行",
|
||||||
|
"缺2027自命题大纲": "仅 18 校有 43 行",
|
||||||
|
"有2027逐专业线": "2 校"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""用官方 CHSI 目录的 tuition_fee 回填点对点学费空行。
|
||||||
|
|
||||||
|
只做 NULL→值,绝不覆盖点对点已有的学费:两源同键不同值属口径冲突,要留着对账。
|
||||||
|
CHSI 该字段是元/年口径(学硕 3 学制均值 8061 元,若为全程应≈24000;
|
||||||
|
与启航「元/年」行按校+专业码对齐 76.2% 完全相等)。
|
||||||
|
全程额按 学制×年费 折算,折算值单独记 tuition_total 并标 derived。
|
||||||
|
"""
|
||||||
|
import csv
|
||||||
|
import gzip
|
||||||
|
import hashlib
|
||||||
|
import io
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import sqlite3
|
||||||
|
import time
|
||||||
|
|
||||||
|
ZX = r'D:/择校/数据库/zexiao_2027.db'
|
||||||
|
PRE = r'D:/择校/运行暂存/入库前备份/20261101_tuition_fill_pre'
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
z = sqlite3.connect(ZX, timeout=600)
|
||||||
|
z.execute('PRAGMA busy_timeout=600000')
|
||||||
|
q = ("select p.rowid, p.school, p.code, c.tuition_fee, c.duration_years "
|
||||||
|
"from pd_dir_detail p join chsi_2027_dir c "
|
||||||
|
"on c.dwmc=p.school and c.zydm=substr(p.code,1,6) "
|
||||||
|
"where (p.tuition_year is null or trim(p.tuition_year)='') "
|
||||||
|
"and c.tuition_fee glob '[0-9]*'")
|
||||||
|
rows = z.execute(q).fetchall()
|
||||||
|
print('候选回填行=%d' % len(rows))
|
||||||
|
if not rows:
|
||||||
|
return
|
||||||
|
import os
|
||||||
|
os.makedirs(PRE, exist_ok=True)
|
||||||
|
cols = ['rowid', 'school', 'dept', 'year', 'code', 'major', 'tuition',
|
||||||
|
'tuition_year', 'tuition_total', 'tuition_kind']
|
||||||
|
sel = ','.join('"%s"' % c for c in cols)
|
||||||
|
old = z.execute('select rowid,%s from pd_dir_detail where rowid in (%s)' % (
|
||||||
|
sel, ','.join(str(r[0]) for r in rows))).fetchall()
|
||||||
|
gz = gzip.open(PRE + '/pd_dir_detail_tuition_rows.csv.gz', 'wb')
|
||||||
|
f = io.TextIOWrapper(gz, encoding='utf-8', newline='')
|
||||||
|
w = csv.writer(f)
|
||||||
|
w.writerow(['rowid'] + cols)
|
||||||
|
for r in old:
|
||||||
|
w.writerow(list(r))
|
||||||
|
f.close()
|
||||||
|
gz.close()
|
||||||
|
sha = hashlib.sha256(open(PRE + '/pd_dir_detail_tuition_rows.csv.gz', 'rb').read()).hexdigest()
|
||||||
|
now = time.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
|
|
||||||
|
filled = derived = 0
|
||||||
|
for rid, school, code, fee, dur in rows:
|
||||||
|
v = re.search(r'\d+', str(fee)).group()
|
||||||
|
d = None
|
||||||
|
if dur and re.search(r'\d', str(dur)):
|
||||||
|
dd = float(re.search(r'\d+(\.\d+)?', str(dur)).group())
|
||||||
|
if 1 <= dd <= 8:
|
||||||
|
d = str(int(round(float(v) * dd)))
|
||||||
|
derived += 1
|
||||||
|
z.execute('update pd_dir_detail set tuition_year=?, tuition_total=coalesce(tuition_total,?),'
|
||||||
|
' tuition_kind=? where rowid=? and (tuition_year is null or trim(tuition_year)=\'\')',
|
||||||
|
(v, d, '官方CHSI2027(元/年)', rid))
|
||||||
|
filled += 1
|
||||||
|
z.execute('INSERT INTO changelog VALUES (?,?,?,?,?,?)',
|
||||||
|
(time.strftime('%Y-%m-%d %H:%M:%S'), 'tuition_fill_20261101',
|
||||||
|
'pd_dir_detail', 'update_null_to_value', filled,
|
||||||
|
'用官方CHSI tuition_fee 回填学费NULL;全程额按学制折算%d行(标derived);'
|
||||||
|
'备份 %s' % (derived, sha[:16])))
|
||||||
|
z.commit()
|
||||||
|
json.dump({'table': 'pd_dir_detail', 'rows_targeted': len(rows), 'rows_filled': filled,
|
||||||
|
'derived_total': derived, 'backup_sha256': sha, 'at': now},
|
||||||
|
open(PRE + '/receipt.json', 'w', encoding='utf-8'), ensure_ascii=False, indent=1)
|
||||||
|
left = z.execute("select count(*) from pd_dir_detail where tuition_year is null or trim(tuition_year)=''").fetchone()[0]
|
||||||
|
tot = z.execute("select count(*) from pd_dir_detail where tuition_year glob '[0-9]*'").fetchone()[0]
|
||||||
|
print('回填=%d(其中折算全程=%d) 学费空行余=%d 有值行=%d' % (filled, derived, left, tot))
|
||||||
|
print('quick_check=', z.execute('PRAGMA quick_check').fetchone()[0])
|
||||||
|
z.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""量化官方 CHSI 学费字段能补多少点对点空行,并归因两源差异。"""
|
||||||
|
import re
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
z = sqlite3.connect(r'D:/择校/数据库/zexiao_2027.db', timeout=260)
|
||||||
|
cols = [c[0] for c in z.execute('select * from pd_dir_detail limit 0').description]
|
||||||
|
tc = [c for c in cols if 'tuition' in c.lower()]
|
||||||
|
print('学费相关列:', tc)
|
||||||
|
|
||||||
|
if tc:
|
||||||
|
t0 = tc[0]
|
||||||
|
q = ("select count(*) tot, sum(case when c.tuition_fee is not null and trim(c.tuition_fee)<>'' "
|
||||||
|
"then 1 else 0 end) can from pd_dir_detail p left join chsi_2027_dir c "
|
||||||
|
"on c.dwmc=p.school and c.zydm=substr(p.code,1,6) "
|
||||||
|
"where p.\"%s\" is null or trim(p.\"%s\")=''" % (t0, t0))
|
||||||
|
print('点对点学费空行 / 其中 CHSI 有官方值:', z.execute(q).fetchone())
|
||||||
|
|
||||||
|
rows = z.execute(
|
||||||
|
"select c.tuition_fee,q.tuition_amount,q.tuition_unit,c.xxfsmc "
|
||||||
|
"from chsi_2027_dir c join qihang_tuition q "
|
||||||
|
"on q.school=c.dwmc and substr(q.major_code,1,6)=c.zydm "
|
||||||
|
"where c.tuition_fee glob '[0-9]*' and q.tuition_amount glob '[0-9]*' limit 8000").fetchall()
|
||||||
|
twice = other = same = 0
|
||||||
|
unit = {}
|
||||||
|
half = 0
|
||||||
|
for chi, qih, u, xxfs in rows:
|
||||||
|
a, b = int(re.search(r'\d+', str(chi)).group()), int(re.search(r'\d+', str(qih)).group())
|
||||||
|
if a == b:
|
||||||
|
same += 1
|
||||||
|
continue
|
||||||
|
if b == 2 * a or a == 2 * b:
|
||||||
|
twice += 1
|
||||||
|
else:
|
||||||
|
other += 1
|
||||||
|
if b > a:
|
||||||
|
half += 1
|
||||||
|
k = str(u)[:10]
|
||||||
|
unit[k] = unit.get(k, 0) + 1
|
||||||
|
print('可比=%d 相等=%d(%.1f%%) 差异=%d(其中2倍关系=%d,一方高于另一方=%d)'
|
||||||
|
% (len(rows), same, 100.0 * same / max(1, len(rows)), twice + other, twice, half))
|
||||||
|
print('差异例的启航单位分布:', unit)
|
||||||
|
print('全体启航单位:', z.execute(
|
||||||
|
"select tuition_unit,count(*) from qihang_tuition group by 1 order by 2 desc limit 5").fetchall())
|
||||||
|
print('\nCHSI 官方学费覆盖: 行=%s 校=%s' % z.execute(
|
||||||
|
"select count(*),count(distinct dwdm) from chsi_2027_dir "
|
||||||
|
"where tuition_fee glob '[0-9]*'").fetchone())
|
||||||
Reference in new issue
Block a user