def generate_csv_url(sheet_url):
    """
    Utility function for generating csv URL from a google sheets link
    This function generates a link to a csv file from a link used to edit a google sheets file.
    The gid must be present in the URL.
    Parameters
    ----------
    sheet_url : str
        The URL for the google sheet file
    
    Returns
    -------
    str
        URL for the csv file
    """
    if type(sheet_url) == str:

        if(sheet_url.find("edit#gid") > -1):
            return sheet_url.replace("edit#gid", "export?format=csv&gid")

        else:
            raise ValueError("sheet_url must contain 'edit#gid' phrase")
    else:
        raise TypeError("sheet_url must be a string")