@cache_json('cbsa_lookup.json')
def cbsa_lookup():
    '\n    Construct a County->CBSA Lookup table from NBER data\n    Returns: dict\n        each key is a (State Code, County FIPS code) tuple\n        each value is a (CBSA FIPS code, CBSA Name) tuple\n    '
    logging.info('Beginning CBSA lookup')
    cbsa_lookup = defaultdict(dict)
    download = requests.get(URL)
    decoded_content = download.content.decode('latin-1').encode('utf-8')
    reader = csv.reader(decoded_content.splitlines(), delimiter=',')
    next(reader)
    for row in reader:
        state_code = row[1]
        fipscounty = row[3][(- 3):]
        cbsa = row[4]
        cbsaname = row[5]
        cbsa_lookup[state_code][fipscounty] = (cbsa, cbsaname)
    return cbsa_lookup
Construct a County->CBSA Lookup table from NBER data
Returns: dict
    each key is a (State Code, County FIPS code) tuple
    each value is a (CBSA FIPS code, CBSA Name) tuple
@cache_json('cbsa_lookup.json')
def cbsa_lookup():
    '\n    Construct a County->CBSA Lookup table from NBER data\n    Returns: dict\n        each key is a (State Code, County FIPS code) tuple\n        each value is a (CBSA FIPS code, CBSA Name) tuple\n    '
    logging.info('Beginning CBSA lookup')
    cbsa_lookup = defaultdict(dict)
    download = requests.get(URL)
    decoded_content = download.content.decode('latin-1').encode('utf-8')
    reader = csv.reader(decoded_content.splitlines(), delimiter=',')
    next(reader)
    for row in reader:
        state_code = row[1]
        fipscounty = row[3][(- 3):]
        cbsa = row[4]
        cbsaname = row[5]
        cbsa_lookup[state_code][fipscounty] = (cbsa, cbsaname)
    return cbsa_lookup