| 123456789101112131415161718192021222324 |
- """
- CSV 数据读取(服务器无法直连PG/CH时,从本地导出的CSV读)
- 返回格式与 db_reader 兼容:list[dict]
- """
- import csv
- def read_card_master_csv(path):
- """读卡牌图库CSV。返回 [{card_id, card_name_ch, language, year, card_no, pg_label, img_url}, ...]"""
- rows = []
- with open(path, "r", encoding="utf-8-sig") as f:
- for r in csv.DictReader(f):
- if r.get("img_url"):
- rows.append(r)
- return rows
- def read_transactions_csv(path):
- """读交易CSV。返回 [{tx_id, platform, title, image_uri, ...}, ...]"""
- rows = []
- with open(path, "r", encoding="utf-8-sig") as f:
- for r in csv.DictReader(f):
- rows.append(r)
- return rows
|