#NEWLINE# def load( self , file_obj , header = True , **kwargs ) : #NEWLINE# #INDENT# count = 0 #NEWLINE# reader = csv . reader ( file_obj , ** kwargs ) #NEWLINE# if header : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# header_keys = next ( reader ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# return count #NEWLINE# #UNINDENT# if self . strict : #NEWLINE# #INDENT# header_fields = [ ] #NEWLINE# for ( idx , key ) in enumerate ( header_keys ) : #NEWLINE# #INDENT# if ( key in header . columns ) : #NEWLINE# #INDENT# header_fields . append ( ( idx , self . columns [ key ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# header_fields = list ( enumerate ( header_keys ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# header_fields = list ( enumerate ( self . model . _meta . sorted_fields ) ) #NEWLINE# #UNINDENT# if ( not header_fields ) : #NEWLINE# #INDENT# return count #NEWLINE# #UNINDENT# for row in reader : #NEWLINE# #INDENT# obj = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( idx , field ) in header_fields : #NEWLINE# #INDENT# if self . strict : #NEWLINE# #INDENT# obj [ field . name ] = field . python_value ( row [ idx ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# obj [ field ] = row [ idx ] #NEWLINE# #UNINDENT# #UNINDENT# self . table . insert ( ** obj ) #NEWLINE# count += 1 #NEWLINE# #UNINDENT# return count