Use standalone 投手.xlsx as the roster source
Monthly data files no longer carry a 投手 sheet, so build_data.py now prefers a standalone 投手.xlsx and falls back to the newest embedded sheet. This roster is content-identical to the 2608 embedded one, so data.json is unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+11
-2
@@ -11,6 +11,7 @@ HERE = os.path.dirname(os.path.abspath(__file__))
|
|||||||
# 源文件按月滚动(2608 -> 2609 -> ...)。全部读进来合并:
|
# 源文件按月滚动(2608 -> 2609 -> ...)。全部读进来合并:
|
||||||
# 同一天出现在多个文件时,以文件名较新的为准(源表会修订历史数据)。
|
# 同一天出现在多个文件时,以文件名较新的为准(源表会修订历史数据)。
|
||||||
SRC_FILES = sorted(glob.glob(os.path.join(HERE, '*每日数据-武汉萌奇熊.xlsx')))
|
SRC_FILES = sorted(glob.glob(os.path.join(HERE, '*每日数据-武汉萌奇熊.xlsx')))
|
||||||
|
# 花名册 投手.xlsx 单独处理,不参与消耗数据合并
|
||||||
if not SRC_FILES:
|
if not SRC_FILES:
|
||||||
sys.exit('ERROR: 仓库里找不到 *每日数据-武汉萌奇熊.xlsx')
|
sys.exit('ERROR: 仓库里找不到 *每日数据-武汉萌奇熊.xlsx')
|
||||||
_cfg = json.load(open(os.path.join(HERE, 'exclude.json')))
|
_cfg = json.load(open(os.path.join(HERE, 'exclude.json')))
|
||||||
@@ -26,14 +27,22 @@ def key(v):
|
|||||||
|
|
||||||
books = [(f, openpyxl.load_workbook(f, data_only=True)) for f in SRC_FILES]
|
books = [(f, openpyxl.load_workbook(f, data_only=True)) for f in SRC_FILES]
|
||||||
|
|
||||||
# --- 投手表:取最新一个带「投手」sheet 的文件(月度文件可能不含该表)---
|
# --- 投手花名册 ---
|
||||||
|
# 优先用独立的 投手.xlsx(月度数据文件已不再带「投手」sheet);
|
||||||
|
# 没有它时退回到最新一个仍带该 sheet 的月度文件。
|
||||||
|
ROSTER_XLSX = os.path.join(HERE, '投手.xlsx')
|
||||||
roster_file, roster = None, None
|
roster_file, roster = None, None
|
||||||
|
if os.path.exists(ROSTER_XLSX):
|
||||||
|
_rwb = openpyxl.load_workbook(ROSTER_XLSX, data_only=True)
|
||||||
|
roster_file = ROSTER_XLSX
|
||||||
|
roster = _rwb['投手'] if '投手' in _rwb.sheetnames else _rwb[_rwb.sheetnames[0]]
|
||||||
|
else:
|
||||||
for f, wb_ in reversed(books):
|
for f, wb_ in reversed(books):
|
||||||
if '投手' in wb_.sheetnames:
|
if '投手' in wb_.sheetnames:
|
||||||
roster_file, roster = f, wb_['投手']
|
roster_file, roster = f, wb_['投手']
|
||||||
break
|
break
|
||||||
if roster is None:
|
if roster is None:
|
||||||
sys.exit('ERROR: 所有源文件都没有「投手」sheet,无法归属投放人')
|
sys.exit('ERROR: 既没有 投手.xlsx,月度文件里也没有「投手」sheet,无法归属投放人')
|
||||||
|
|
||||||
amap = {}
|
amap = {}
|
||||||
dropped_ids = set(EXCL_ADP) # 先纳入按 Adpingid 剔除的,再补上按包名命中的
|
dropped_ids = set(EXCL_ADP) # 先纳入按 Adpingid 剔除的,再补上按包名命中的
|
||||||
|
|||||||
Reference in New Issue
Block a user