layer2 commit
This commit is contained in:
23
layer2/PGEE/code/renum.py
Normal file
23
layer2/PGEE/code/renum.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import json
|
||||
|
||||
def renumber_json_indices(input_file, output_file):
|
||||
|
||||
with open(input_file, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
idx = 1
|
||||
|
||||
for item in data:
|
||||
item['idx'] = idx
|
||||
idx = idx + 1
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||
|
||||
print(f"成功将索引重新编号并保存到 {output_file}")
|
||||
print(f"处理了 {len(data)} 条数据")
|
||||
|
||||
if __name__ == "__main__":
|
||||
input_file = "/home/ubuntu/50T/fsy/layer2/QA/single_select.json" # 替换为你的输入文件名
|
||||
output_file = "/home/ubuntu/50T/fsy/layer2/QA/single_select_renum.json" # 替换为你想要的输出文件名
|
||||
|
||||
renumber_json_indices(input_file, output_file)
|
||||
Reference in New Issue
Block a user