def METHOD_NAME(
    tmp_path: Path,
    data_frame: pd.DataFrame,
    index: bool,
    extension: str,
    delimiter: str,
    header: bool,
    blank_lines_before_header: int,
    blank_lines_after_header: int,
    comment_prefix: str,
    n_comment_lines: int,
    n_trailing_spaces: int,
):
    file_name = tmp_path / f"data{extension}"
    comment_str = "\n".join(
        f"{comment_prefix}comment{i}" for i in range(1, n_comment_lines + 1)
    )
    if len(comment_str) > 0:
        comment_str += "\n"
    data_frame_str = data_frame.to_csv(sep="\1", header=True, index=index)
    assert isinstance(data_frame_str, str)
    data_frame_str = data_frame_str.replace("\1", delimiter)
    data_frame_lines = data_frame_str.splitlines()
    header_str = data_frame_lines[0]
    data_lines = data_frame_lines[1:]
    trailing_spaces_str = " " * n_trailing_spaces
    with open(file_name, "w") as file_pointer:
        file_pointer.write(comment_str)
        for _ in range(blank_lines_before_header):
            file_pointer.write("\n")
        if header:
            file_pointer.write(header_str)
            file_pointer.write(trailing_spaces_str)
            file_pointer.write("\n")
        for _ in range(blank_lines_after_header):
            file_pointer.write("\n")
        for data_line in data_lines:
            file_pointer.write(data_line)
            file_pointer.write(trailing_spaces_str)
            file_pointer.write("\n")
    spreadsheet = read_spreadsheet(file_name)
    if header:
        assert all(a == b for a, b in zip(data_frame.columns, spreadsheet.columns))
    assert np.allclose(data_frame.values, spreadsheet.values)