from pathlib import Path


def dump_data(directory, file_name, data):
    """
    dump_data(directory, file_name, data)

    Writes an iterable of iterables, such as a list of lists, row by row to a
    csv file. Useful for logging a large chunk of data at once after test or
    measurement.

    The arguements "directory" and "file_name" specify the path of the file to
    be created. The log file will be storted at directory/file_name.csv,
    file_name itself does not need to contain the file extension, it will
    automatically be added.

    The iterable "data" can contain an arbitrary number of elements which in
    turn can have arbitrary length and data type as long as it can be safely
    cast to a string. For example:

    data = [["column A", "column B", "column C"], [1, 2, 3], [4, 5, 6]]
    dump_data("some_directory", "my_data", data)

    Each element of data does not need to have the same length but it is
    recommended to make parsing the data after the fact easier.

    Args:
        directory (str, or path-like object): file directory where the log file
            is/will be stored.
        file_name (str): name of the log file to use, does not need to include
            the file extension.
        data: an iterable of iterables of data to be stored.

    Returns:
        NoneType
    """

    with open(Path(directory) / f'{file_name}.csv', 'w') as f:

        for item in data:
            print(*item, sep=',', file=f)

    return None