#NEWLINE# def load( self ) : #NEWLINE# #INDENT# self . _common_kwargs = self . _build_common_election_kwargs ( ) #NEWLINE# self . _common_kwargs [ 'reporting_level' ] = 'precinct' #NEWLINE# results = [ ] #NEWLINE# with self . _file_handle as csvfile : #NEWLINE# #INDENT# reader = unicodecsv . DictReader ( csvfile , encoding = 'latin-1' , fieldnames = ( 'Jurisdiction' , 'Precinct' , 'office' , 'candidate' , 'Votes' ) ) #NEWLINE# next ( reader , None ) #NEWLINE# next ( reader , None ) #NEWLINE# next ( reader , None ) #NEWLINE# next ( reader , None ) #NEWLINE# for row in reader : #NEWLINE# #INDENT# if self . _skip_row ( row ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# rr_kwargs = self . _common_kwargs . copy ( ) #NEWLINE# rr_kwargs . update ( self . _build_contest_kwargs ( row ) ) #NEWLINE# rr_kwargs . update ( self . _build_candidate_kwargs ( row ) ) #NEWLINE# ocd_id = [ c for c in self . datasource . _jurisdictions ( ) if ( c [ 'jurisdiction' ] == row [ 'Jurisdiction' ] ) ] [ 0 ] [ 'ocd_id' ] #NEWLINE# jurisdiction = row [ 'Precinct' ] . strip ( ) #NEWLINE# if ( row [ 'Votes' ] . strip ( ) == '*' ) : #NEWLINE# #INDENT# votes = 'N/A' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# votes = int ( row [ 'Votes' ] . replace ( ',' , '' ) . strip ( ) ) #NEWLINE# #UNINDENT# rr_kwargs . update ( { #NEWLINE# #INDENT# 'jurisdiction' : jurisdiction , #NEWLINE# 'parent_jurisdiction' : row [ 'Jurisdiction' ] , #NEWLINE# 'ocd_id' : '{}/precinct:{}' . format ( self . mapping [ 'ocd_id' ] , ocd_type_id ( row [ 'Precinct' ] ) ) , #NEWLINE# 'votes' : votes , #NEWLINE# #UNINDENT# } ) #NEWLINE# results . append ( RawResult ( ** rr_kwargs ) ) #NEWLINE# #UNINDENT# #UNINDENT# RawResult . objects . insert ( results )