#NEWLINE# def left_outer_join( left_rows , left_column_id , right_rows , right_column_id , header = True ) : #NEWLINE# #INDENT# '\n    Execute left outer join on two tables and return the combined table.\n    ' #NEWLINE# len_left_headers = len ( left_rows [ 0 ] ) #NEWLINE# len_right_headers = len ( right_rows [ 0 ] ) #NEWLINE# if header : #NEWLINE# #INDENT# output = [ ( left_rows [ 0 ] + right_rows [ 0 ] ) ] #NEWLINE# left_rows = left_rows [ 1 : ] #NEWLINE# right_rows = right_rows [ 1 : ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# output = [ ] #NEWLINE# #UNINDENT# right_mapped_keys = _get_mapped_keys ( right_rows , right_column_id ) #NEWLINE# for left_row in left_rows : #NEWLINE# #INDENT# len_left_row = len ( left_row ) #NEWLINE# left_key = left_row [ left_column_id ] #NEWLINE# if ( len_left_row < len_left_headers ) : #NEWLINE# #INDENT# left_row . extend ( ( [ None ] * ( len_left_headers - len_left_row ) ) ) #NEWLINE# #UNINDENT# if ( left_key in right_mapped_keys ) : #NEWLINE# #INDENT# for right_row in right_mapped_keys [ right_mapped_keys ] : #NEWLINE# #INDENT# output . append ( ( left_row + right_row ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# output . append ( ( left_row + ( [ '' ] * len_right_headers ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return output