def _check_csv(data):
    """
    Returns a string representing an error message if data is malformed [INTERNAL FUNCTION]
    
    If the data is a properly formed CSV value, this function returns the empty string.
    
    Parameter data: The Python value to encode as a CSV file
    Precondition: None
    """
    from functools import reduce
    if type(data) not in [tuple, list]:
        return 'CSV data is neither a tuple nor a list'
    if not (type(data[0]) in [tuple, list] and reduce(lambda a, b: a and 
        type(b) == str, data[0])):
        return 'Row %s is not a valid CSV header' % repr(data[0])
    headlen = len(data[0])
    for pos in range(1, len(data)):
        if type(data[pos]) not in [tuple, list]:
            return 'Row %d is malformed' % pos
        elif len(data[pos]) != headlen:
            return 'Row %d does not match the header length' % pos
    return ''
