Initial commit
This commit is contained in:
80
xuexiao/etl/create_sample_workbooks.py
Normal file
80
xuexiao/etl/create_sample_workbooks.py
Normal file
@@ -0,0 +1,80 @@
|
||||
"""生成示例课时核对表(3月+4月,用于 ETL 冒烟测试)"""
|
||||
from pathlib import Path
|
||||
|
||||
from openpyxl import Workbook
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
OUT = ROOT / 'keshibiao'
|
||||
|
||||
|
||||
def _write_month(path: Path, year: int, month: int, prev_label: str, rows: list):
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = 'code学龄后'
|
||||
ws.append([f'达尔琳{year}年{month}月份code学员课时明细'])
|
||||
headers = [
|
||||
'序号', '学员姓名', '课程级别',
|
||||
f'{prev_label}剩余课时', '赠送课时', f'{prev_label}剩余总课时',
|
||||
'单价', f'{prev_label}末剩余金额',
|
||||
'新签金额', '新签课时', '新签赠送课时',
|
||||
'续费金额', '续费课时', '续费赠送课时',
|
||||
f'{month}月已上课时', f'{month}月已上金额',
|
||||
'退费课时', '账号费', '退赠送课时', '退费金额',
|
||||
f'{month}月剩余课时', f'{month}月剩余总课时', f'{month}月末剩余金额',
|
||||
'', '', '', '备注',
|
||||
]
|
||||
ws.append(headers)
|
||||
for row in rows:
|
||||
ws.append(row)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
wb.save(path)
|
||||
print('wrote', path)
|
||||
|
||||
|
||||
def main():
|
||||
# 3月:杨霈淞示例
|
||||
_write_month(
|
||||
OUT / '课时核对表_2026_3月份.xlsx', 2026, 3, '2月',
|
||||
[[
|
||||
1, '杨霈淞', 'scratch',
|
||||
68, 8, 76, 96.875, 6703.7,
|
||||
None, None, None,
|
||||
None, None, None,
|
||||
6, 581.25,
|
||||
None, None, None, None,
|
||||
62, 70, 6122.45,
|
||||
'3.8', '3.15', '3.29', '',
|
||||
]],
|
||||
)
|
||||
# 4月:链式衔接
|
||||
_write_month(
|
||||
OUT / '课时核对表_2026_4月份.xlsx', 2026, 4, '3月',
|
||||
[[
|
||||
1, '杨霈淞', 'scratch',
|
||||
62, 8, 70, 96.875, 6122.45,
|
||||
None, None, None,
|
||||
None, None, None,
|
||||
6, 581.25,
|
||||
None, None, None, None,
|
||||
56, 64, 5541.2,
|
||||
'4.5', '4.12', '4.19', '',
|
||||
]],
|
||||
)
|
||||
# 新签学员示例
|
||||
_write_month(
|
||||
OUT / '课时核对表_2026_5月份.xlsx', 2026, 5, '4月',
|
||||
[[
|
||||
None, '柳昱泽(三月)', 'python',
|
||||
None, None, None, None, None,
|
||||
9600, 48, 4,
|
||||
None, None, None,
|
||||
4, 800,
|
||||
None, None, None, None,
|
||||
44, 48, 8800,
|
||||
'5.10', '5.17', '', '5月新签',
|
||||
]],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user