Ejemplo n.º 1
0
def hifld_national():
#['VAL_DATE', 'NAICS_DESC', 'COUNTRY', 'NAICS_CODE', 'UNITS', 'RevGeoFlag', 'SOURCEDATE', 'MHPID', 'WEBSITE', 'VAL_METHOD', 'SOURCE', 'ZIP4', 'STATUS', 'COUNTYFIPS', 'ZIP', '\xef\xbb\xbfX', 'LONGITUDE', 'COUNTY', 'STATE', 'FID', 'Y', 'SIZE', 'CITY', 'YEARBLT', 'NAME', 'ADDRESS2', 'TELEPHONE', 'ADDRESS', 'LATITUDE', 'TYPE']

    payload = tpcsv.open_source_csv('source_files/HIFLD_Mobile_Home_Parks.csv')
    
    data = payload[0]
    headers = payload[1]
    
    parks = []

    for park in data:

        if park['NAICS_CODE'] == '721211':
            continue

        else:    
            address = park['ADDRESS']
            county = park['COUNTY']
            state = park['STATE']
            zipcode = park['ZIP']
            name = park['NAME']
            city = park['CITY']
            total_lots = park['UNITS']
            phone_number = park['TELEPHONE']
            website = park['WEBSITE']
            
            info_list = [
                        str("total_lots:" + total_lots),
                        str("phone_number:" + phone_number), 
                        str("zipcode:" + zipcode),
                        str("website:" + website)
                        ]
            info = "\n".join(info_list)
    
            geo_location = str(park['LATITUDE']) + ", " + str(park['LONGITUDE'])
            
            information = db.apply_schema(
                                park_name = name,
                                park_county = county,
                                park_address = address,
                                city = city,
                                park_info = info,
                                other_contact_info = phone_number,
                                geo_location = geo_location,
                                state = state,
                                total_lots = total_lots
                                )
            
            park_a = [information]
            parks.append(information)
                
            print "  ::  {}   ::    {}".format(information['park_name'], information['geo_location'])

            tpcsv.write_source_csv(park_a, "pa_complete.csv")
    
    return parks
Ejemplo n.º 2
0
def mh_village_PA():
#ID,Name,Address,City,State,Zip,County,"Site Count","Average Monthly Rent","Phone Number","Vacant Sites"

    payload = tpcsv.open_source_csv('source_files/PACommunityReport.csv')
    
    data = payload[0]
    headers = payload[1]
    
    parks = []

    for park in data:
        address = park['Address']
        county = park['County']
        state = park['State']
        zipcode = park['Zip']
        name = park['Name']
        city = park['City']
        total_lots = park['Site Count']
        avg_rent = park['Average Monthly Rent']
        phone_number = park['Phone Number']
        vacant_lots = park['Vacant Sites']
        
        info_list = [
                    str("total_lots:" + total_lots),
                    str("avg_rent:" + avg_rent),
                    str("phone_number:" + phone_number), 
                    str("vacant_lots:" + vacant_lots),
                    str("zipcode:" + zipcode),
                    ]
        info = "\n".join(info_list)
    
        geo_location = get_park_geolocation(address, county, state, zipcode)

        information = db.apply_schema(
                            park_name = name,
                            park_county = county,
                            park_address = address,
                            city = city,
                            park_info = info,
                            other_contact_info = phone_number,
                            geo_location = geo_location,
                            state = state,
                            total_lots = total_lots
                            )
        
        park_a = [information]
        parks.append(information)
            
        print "  ::  {}   ::    {}".format(information['park_name'], information['geo_location'])

        tpcsv.write_source_csv(park_a, "pa_complete.csv")
    
    return parks