import pandas as pd
from core.models import NewBusiness

DATA_SOURCES = {
    "bank": "data/Bank.csv",
    "church": "data/Church.csv",
    "cinema": "data/cinema.csv",
    "school": "data/elem_secon_school.csv",
    "fitness": "data/Fitness_Wellness.csv",
    "grocery": "data/Gerocery.csv",
    "nightlife": "data/Nightlife.csv",
    "pharmacy": "data/Pharmacy.csv",
    "restaurant": "data/Restaurant.csv",
}

for category, source in DATA_SOURCES.iteritems():
    data = pd.read_csv(source)
    print category
    for index, row in data.iterrows():
        NewBusiness(
            category=category,
            fid=row["FID"],
            company_name=row["COMPANY_NAME"],
            address=row["ADDRESS"],
            city=row["CITY"],
            state=row["STATE"],
            zipcode=row["ZIPCODE"],
            latitude=row["LATITUDE"],
            longitude=row["LONGITUDE"],
            naics2=row["NAICS2"],
            naics_code=row["NAICS CODE"],
            industry_description=row["Industry Description"],
            indu_emp=row["INDU_EMP"],
            serv_emp=row["SERV_EMP"],
            comm_emp=row["COMM_EMP"],
            estemp=row["ESTEMP"],
            totalpop=row["TOTALPOP"],
            households=row["HOUSEHOLDS"],
            male=row["MALE"],
            female=row["FEMALE"],
            percent_male=float(row["%Male"][:-1]),
            percent_female=float(row["%FEMALE"][:-1]),
            white=row["WHITE"],
            black=row["BLACK"],
            ameri_es=row["AMERI_ES"],
            asian=row["ASIAN"],
            hawn_pi=row["HAWN_PI"],
            other=row["OTHER"],
            mult_race=row["MULT_RACE"],
            hispanic=row["HISPANIC"],
            white_nh=row["WHITE_NH"],
            percent_white=row["%WHITE"],
            percent_black=row["%BLACK"],
            percent_indian=row["%INDIAN"],
            percent_asian=row["%ASIAN"],
            pct_hawn=row["PCT_HAWN"],
            percent_other=row["%OTHER"],
            percent_multi=row["%MULTI"],
            percent_hisp=row["%HISP"],
            average_household_size=row["AVERAGE_HOUSEHOLD_SIZE"],
            age_below_18=row["AGE_BELOW_18"],
            age_18_40=row["AGE_18_40"],
            age_40_65=row["AGE_40_65"],
            age_65_plus=row["AGE_65+"],
            age_median=row["AGE_MEDIAN"],
            tran_total=row["TRAN_TOTAL"],
            tran_car=row["TRAN_CAR"],
            tran_moto=row["TRAN_MOTO"],
            tran_bike=row["TRAN_BIKE"],
            tran_pub=row["TRAN_PUB"],
            tran_walk=row["TRAN_WALK"],
            tran_other=row["TRAN_OTHER"],
            tran_home=row["TRAN_HOME"],
            currently_student=row["CURRENTLY_STUDENT"],
            currently_not_student=row["CURRENTLY_NOT_STUDENT"],
            less_10k=row["LESS_$10K"],
            i10k_14k=row["I10K_14K"],
            i15k_19k=row["I15K_19K"],
            i20k_24k=row["I20K_24K"],
            i25k_29k=row["I25K_29K"],
            i30k_34k=row["I30K_34K"],
            i35k_39k=row["I35K_39K"],
            i40k_44k=row["I40K_44K"],
            i45k_49k=row["I45K_49K"],
            i50k_59k=row["I50K_59K"],
            i60k_74k=row["I60K_74K"],
            i75k_99k=row["I75K_99K"],
            i100k_124k=row["I100K_124K"],
            i125k_149k=row["I125K_149K"],
            i150k_199k=row["I150K_199K"],
            i200kmore=row["I200KMORE"],
            median_household_income=row["MEDIAN_HOUSEHOLD_INCOME"],
            percent_bachelor_degree=row["%_BACHELOR_DEGREE"],
            percent_poverty=row["%POVERTY"]
        ).save()
