| import json | |
| def fix_file_number(start, nodes): | |
| for i in range(len(nodes)): | |
| nodes[i]["file_number"] = start + i | |
| return start + len(nodes) | |
| # Function to load JSON data from a file | |
| def load_json(file_path): | |
| with open(file_path, 'r') as file: | |
| return json.load(file) | |
| # Function to save JSON data to a file | |
| def save_json(data, file_path): | |
| with open(file_path, 'w') as file: | |
| json.dump(data, file, indent=4) | |
| # Function to concatenate JSON files | |
| def concat_json_files(files_to_concat): | |
| concatenated_data = [] | |
| start_index = 0 | |
| for i in range(len(files_to_concat)): | |
| data = load_json(files_to_concat[i]) # Load data from each file | |
| start_index = fix_file_number(start_index, data) # Concatenate data | |
| concatenated_data += data | |
| output_file = f"../dig-bench-concat.json" | |
| save_json(concatenated_data, output_file) # Save concatenated data to the new file | |
| print(f"Concatenated data saved to {output_file}") | |
| def main(): | |
| # Replace with your actual dig-bench.json files | |
| files_to_concat = [ | |
| # 'barley-3-7.json', # failed | |
| # 'barley.json', # passed | |
| # 'birdstrikes.json', # passed | |
| # 'burtin-3-7.json', # failed: Duplicate scale or projection name: "child__row_Displacementcolumn_Horsepower_x" | |
| # 'burtin-2-7.json', | |
| 'cars-3-7.json', | |
| # 'cars-2-7.json', | |
| # 'cars-2-7_2.json', | |
| # 'crimea-3-7.json', # passed | |
| # 'driving-3-7.json', | |
| # 'iris-3-7.json', # failed | |
| # 'iris-3-7_2.json', # | |
| # 'iris-2-7.json', # | |
| # 'jobs.json', | |
| # 'movies-3-7.json', # failed | |
| # 'population-3-7.json', # failed | |
| # 'population-3-7_2.json' # ? | |
| ] | |
| # files_to_concat = ['dig-bench.json'] | |
| # Call the function to concatenate the files | |
| concat_json_files(files_to_concat) | |
| if __name__ == "__main__": | |
| main() | |