Update: 初学记、佩文韵府 and 五车韵瑞
This commit is contained in:
28
佩文韵府/fix_volume.py
Normal file
28
佩文韵府/fix_volume.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import json
|
||||
|
||||
print("Loading peiwenyunfu.json...")
|
||||
with open('peiwenyunfu.json', 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
current_vol = ""
|
||||
fixed_count = 0
|
||||
|
||||
for rhyme, r_data in data.items():
|
||||
if rhyme in ['metadata', 'preface']:
|
||||
continue
|
||||
|
||||
vol = r_data.get("卷", "")
|
||||
if vol.strip():
|
||||
# Update current valid volume
|
||||
current_vol = vol.strip()
|
||||
else:
|
||||
# If volume is empty, use the current_vol
|
||||
if current_vol:
|
||||
r_data["卷"] = current_vol
|
||||
fixed_count += 1
|
||||
|
||||
print(f"Fixed {fixed_count} missing volumes.")
|
||||
|
||||
with open('peiwenyunfu.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
print("Saved to peiwenyunfu.json!")
|
||||
Reference in New Issue
Block a user