Пример #1
0
def scrape_fiona_metadata(obj, source):
    """
    Uses openaddress machine code to scrape metadata from a fiona object.
    """
    source_json = json.loads(open('{}/sources/{}'.format(config.openaddr_dir, source)).read())
    cleaned_json = conform_smash_case(source_json)
    cleaned_prop = {k: str(v or '') for (k, v) in  obj['properties'].items()}

    metadata = row_transform_and_convert(cleaned_json, cleaned_prop)

    return metadata
Пример #2
0
def scrape_csv_metadata(row, header, source):
    """
    Uses openaddress machine code to scrape metadata from a csv row.
    """
    props = {}

    source_json = json.loads(open('{}/sources/{}'.format(config.openaddr_dir, source)).read())
    cleaned_json = conform_smash_case(source_json)
    for key in header:
        if key != 'OA:geom':
            props[key] = row[header.index(key)]

    cleaned_prop = {k: str(v or '') for (k, v) in  props.items()}
    metadata = row_transform_and_convert(cleaned_json, cleaned_prop)

    return metadata