def write_csv_file()

in fiosynth_lib/fio_json_parser.py [0:0]


def write_csv_file(csv_filepath, fio_json_files):
    """Converts and writes each fio json file into a single CSV file."""
    is_new_file = not os.path.isfile(csv_filepath)
    with open(csv_filepath, "a") as csv_out:
        first_file = fio_json_files[0]
        fio_jobname = os.path.splitext(os.path.basename(first_file))[0]
        fio_data = read_json(first_file)
        if is_new_file:
            new_csv(
                csv_out,
                ("percentile_list" in fio_data["jobs"][0]["job options"]),
                "percentile_list" in fio_data["global options"],
            )
        print_csv_line(csv_out, fio_jobname, fio_data)
        for f in fio_json_files[1:]:  # Continue from second element, if any
            fio_jobname = os.path.splitext(os.path.basename(f))[0]
            fio_data = read_json(f)
            print_csv_line(csv_out, fio_jobname, fio_data)