import numpy as np import json # file_path = "/home/yiming/ContrastDebugger/EXP/codesearch_simp/Model/Epoch_1/train_data.npy" # # 读取 ndarray 数据 # data = np.load(file_path) # print(len(data)) # # # 选择前 50000 条数据 # # selected_data = data[:50000] # # # 重新保存到文件中 # # np.save(file_path, selected_data) # idxs = [i for i in range(len(data))] # idxs_path = "/home/yiming/ContrastDebugger/EXP/codesearch_simp/Model/Epoch_1/index.json" # json_file = open(idxs_path, mode='w') # json.dump(idxs, json_file, indent=4) input_file = "/home/yiming/ContrastDebugger/EXP/codesearch_query_simp/Model/label_list.json" output_file = "/home/yiming/ContrastDebugger/EXP/codesearch_query_simp/Model/label.txt" # 读取输入文件 with open(input_file, "r") as f: data = json.load(f) # 选择前 50000 条数据 selected_data = data[:50000] # 将每条数据作为一行存储到输出文件 with open(output_file, "w") as f: for item in selected_data: f.write(item + "\n")