import os import json files = ["gigaspeech_no-previous_test_0-5000.json", "gigaspeech_no-previous_test_5000-10000.json", "gigaspeech_no-previous_test_10000-15000.json", "gigaspeech_no-previous_test_15000-20000.json"] output_file = "gigaspeech_no-previous_test.json" final_output = {} for file in files: with open(file) as f: data = json.load(f) final_output.update(data) with open(output_file, "w") as f: json.dump(final_output, f)