This function writes comma-separated <data> to
    <path>. Parameter <path> is either a pathname or a file-like
    object that supports the |write()| method.

def write_csv(path, data):
    """This function writes comma-separated <data> to
    <path>. Parameter <path> is either a pathname or a file-like
    object that supports the |write()| method."""

    fd = _try_open_file(path, 'w',
                        'The first argument must be a pathname or an object that supports write() method')
    for v in data:
        fd.write(",".join([str(x) for x in v]))
        fd.write("\n")
    _try_close_file(fd, path)