Dear friends
Recently, I have been using English etymology websites https://www.etymonline.com/ In order to organize the short etymological structures that need to be memorized, they are labeled as prefixes, roots, and suffixes. I want to export a Tiddler containing one or more of these three tags through advanced filtering in Tiddlewiki, perform batch deep data processing on Tiddlers.json using Python, and then export them back to Tiddlewiki
This is my attempt from Python. The code runs normally, but the merged JSON data cannot be imported back into tiddlewiki
import json
# 指定要合并的JSON文件列表
json_files = ['tiddlers.json', 'tiddlers (1).json']
# 初始化一个空列表来存储所有JSON文件的内容
merged_data = []
# 遍历所有JSON文件
for filename in json_files:
# 读取JSON文件内容
with open(filename, 'r', encoding='utf-8') as f:
data = json.load(f)
# 将文件内容添加到merged_data列表中
merged_data.append(data)
# 将合并后的数据写入新的JSON文件
with open('merged.json', 'w', encoding='utf-8') as f:
json.dump(merged_data, f, ensure_ascii=False, indent=4)
print('指定的JSON文件已合并为merged.json')
Any answer would be greatly appreciated!
