Ejemplo n.º 1
0
collection = utils.get_geography_collection()

with open(FILENAME) as f:
    rows = UnicodeCSVReader(f)
    headers = rows.next()

    updates = 0
    row_count = 0

    for row in rows:
        row_count += 1
        row_dict = dict(zip(headers, row))

        xref = utils.xref_from_row_dict(row_dict)

        geography = utils.find_geography_by_xref(collection, xref, fields=['data']) 
        if not geography:
            continue

        if YEAR not in geography['data']:
            geography['data'][YEAR] = {}

        tables = {}

        for k, v in row_dict.items():
            # Format table names to match labels
            t = utils.parse_table_from_key(k) 
            
            if t not in tables:
                tables[t] = {}
Ejemplo n.º 2
0
collection = db[config.GEOGRAPHIES_2000_COLLECTION]

with open(FILENAME) as f:
    rows = UnicodeCSVReader(f)
    headers = rows.next()

    updates = 0
    row_count = 0

    for row in rows:
        row_count += 1
        row_dict = dict(zip(headers, row))

        xref = utils.xref_from_row_dict(row_dict)

        geography = utils.find_geography_by_xref(collection, xref) 
        if not geography:
            continue

        if YEAR not in geography['data']:
            geography['data'][YEAR] = {}

        tables = {}

        for k, v in row_dict.items():
            # Format table names to match labels
            t = utils.parse_table_from_key(k) 

            if t not in tables:
                tables[t] = {}
Ejemplo n.º 3
0
with open(FILENAME) as f:
    rows = UnicodeCSVReader(f)
    headers = rows.next()

    updates = 0
    row_count = 0

    for row in rows:
        row_count += 1
        row_dict = dict(zip(headers, row))

        xref = utils.xref_from_row_dict(row_dict)

        geography = utils.find_geography_by_xref(collection,
                                                 xref,
                                                 fields=['data'])
        if not geography:
            continue

        if YEAR not in geography['data']:
            geography['data'][YEAR] = {}

        tables = {}

        for k, v in row_dict.items():
            # Format table names to match labels
            t = utils.parse_table_from_key(k)

            if t not in tables:
                tables[t] = {}
Ejemplo n.º 4
0
collection = utils.get_geography2000_collection()

with open(FILENAME) as f:
    rows = UnicodeCSVReader(f)
    headers = rows.next()

    updates = 0
    row_count = 0

    for row in rows:
        row_count += 1
        row_dict = dict(zip(headers, row))

        xref = utils.xref_from_row_dict(row_dict)

        geography = utils.find_geography_by_xref(collection, xref)
        if not geography:
            continue

        if YEAR not in geography['data']:
            geography['data'][YEAR] = {}

        tables = {}

        for k, v in row_dict.items():
            # Format table names to match labels
            t = utils.parse_table_from_key(k)

            if t not in tables:
                tables[t] = {}