0006_load_final_cases.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:cop-matcher 作者: thechicagoreporter 项目源码 文件源码
def load_new_cases(apps,schema_editor):
    in_file_path = BASE_DIR + '/data/20160620_migration/cases.csv'
    in_file      = open(in_file_path)
    in_csv       = csv.DictReader(in_file)

    for row in in_csv:
        c = Case.objects.create(
                                id                 = row['id'],
                                case_no            = row['CaseNumber'], 
                                date_filed         = parse_str_date(row['DateFiled']),
                                date_closed        = parse_str_date(row['DateClosed']),
                                judge              = row['Judge'],
                                plaintiff_atty     = row['PlaintiffsLeadAttorney'],
                                plaintiff_firm     = row['PlaintiffsAttorneyLawFirm'],
                                city_atty          = row['CitysLeadAttorney'],
                                city_firm          = row['CitysAttorneyLawFirm'],
                                magistrate         = row['MagistrateJudge'],
                                incident_date      = parse_str_date(row['DateofIncident']),             
                                location           = row['LocationListed'],
                                address            = row['StreetAddress'],
                                city               = row['City'],
                                state              = row['State'],
                                lat                = float(row['Latitude']) if row['Latitude'] else None, 
                                lon                = float(row['Longitude']) if row['Longitude'] else None,
                                census_place       = row['CensusPlaceFips'],
                                census_msa         = row['CensusMsaFips'],
                                census_met_div     = row['CensusMetDivFips'],
                                census_mcd         = row['CensusMcdFips'],
                                census_micro       = row['CensusCbsaMicro'],
                                census_cbsa        = row['CensusCbsaFips'],
                                census_block       = row['CensusBlock'],
                                census_block_g     = row['CensusBlockGroup'],
                                census_tract       = row['CensusTract'],
                                census_county      = row['CensusCountyFips'],
                                census_state       = row['CensusStateFips'],
                                naaccr_cert        = row['naaccrCertCode'],
                                m_number           = row['MNumber'],
                                m_predirection     = row['MPreDirectional'],
                                m_name             = row['MName'],
                                m_suffix           = row['MSuffix'],
                                m_city             = row['MCity'],
                                m_state            = row['MState'],
                                narrative          = row['Narrative'],
                                primary_cause      = row['primary_cause'],
                                federal_causes     = row['federal_causes'],
                                state_causes       = row['state_causes'],
                                interaction_type   = row['interaction_type'],
                                officers           = row['officers'],
                                victims            = row['victims'],
                                misconduct_type    = row['misconduct_type'],
                                weapons_used       = row['weapons_used'],
                                outcome            = row['outcome'],
                                tags               = row['tags'],
                                reporter           = row['EnteredBy'],
                                fact_checker       = row['Fact-checkedby'],
                                differences        = row['Differences'],
                               )
        c.save()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号