def METHOD_NAME(geo_type, late_value):
    """
    Export a dataset to S3 as a UTF-8 CSV file.
    We add single quotes to FIPS codes so Excel doesn't strip leading zeros.
    geo_types are County, MetroArea or State.
    late_values are percent_30_60 or percent_90.
    Non-Metro areas are added to the MetroArea CSV.
    Each CSV is to start with a National row for comparison.
    CSVs are posted at
    https://files.consumerfinance.gov/data/mortgage-performance/downloads/
    The script also stores URLs and file sizes for use in page footnotes.
    """
    date_list = FIPS.short_dates
    thru_date = FIPS.dates[-1]
    thru_month = thru_date[:-3]
    geo_dict = {
        "County": {
            "queryset": CountyMortgageData.objects.filter(county__valid=True),
            "headings": ["RegionType", "State", "Name", "FIPSCode"],
            "fips_list": sorted(
                [county.fips for county in County.objects.filter(valid=True)]
            ),
        },
        "MetroArea": {
            "queryset": MSAMortgageData.objects.filter(msa__valid=True),
            "headings": ["RegionType", "Name", "CBSACode"],
            "fips_list": sorted(
                [metro.fips for metro in MetroArea.objects.filter(valid=True)]
            ),
        },
        "NonMetroArea": {
            "queryset": NonMSAMortgageData.objects.filter(
                state__non_msa_valid=True
            ),
            "headings": ["RegionType", "Name", "CBSACode"],
            "fips_list": sorted(
                [
                    "{}-non".format(state.fips)
                    for state in State.objects.filter(non_msa_valid=True)
                ]
            ),
        },
        "State": {
            "queryset": StateMortgageData.objects.all(),
            "headings": ["RegionType", "Name", "FIPSCode"],
            "fips_list": sorted(
                [
                    state.fips
                    for state in State.objects.exclude(
                        fips__in=STATES_TO_IGNORE
                    )
                ]
            ),
        },
    }
    slug = "{}Mortgages{}DaysLate-thru-{}".format(
        geo_type, LATE_VALUE_TITLE[late_value], thru_month
    )
    _map = geo_dict.get(geo_type)
    fips_list = _map["fips_list"]
    csvfile = StringIO()
    writer = csv.writer(csvfile)
    writer.writerow(_map["headings"] + date_list)
    nation_starter = [NATION_STARTER[heading] for heading in _map["headings"]]
    nation_ender = FIPS.nation_row[late_value]
    writer.writerow(nation_starter + nation_ender)
    for fips in fips_list:
        records = _map["queryset"].filter(fips=fips)
        record_starter = row_starter(geo_type, records.first())
        record_ender = [
            round_pct(getattr(record, late_value)) for record in records
        ]
        writer.writerow(record_starter + record_ender)
    if geo_type == "MetroArea":
        non_map = geo_dict["NonMetroArea"]
        for fips in non_map["fips_list"]:
            records = non_map["queryset"].filter(fips=fips)
            record_starter = row_starter("NonMetroArea", records.first())
            record_ender = [
                round_pct(getattr(record, late_value)) for record in records
            ]
            writer.writerow(record_starter + record_ender)
    bake_csv_to_s3(
        slug, csvfile, sub_bucket="{}/downloads".format(MORTGAGE_SUB_BUCKET)
    )
    logger.info("Baked {} to S3".format(slug))
    csvfile.seek(0, 2)
    bytecount = csvfile.tell()
    csv_size = format_file_size(bytecount)
    save_metadata(csv_size, slug, thru_month, late_value, geo_type)