#NEWLINE# def andfilter( cvsfile , write_func , * args ) : #NEWLINE# #INDENT# '\n    \n    ' #NEWLINE# argv = args [ 0 ] #NEWLINE# if ( len ( argv ) < 2 ) : #NEWLINE# #INDENT# sys . stderr . write ( "Need two extra arguments for 'organize', e.g. command: <1,2,3> <4,5,6> means the first 1,2,3 will be used as dependent variables/response, and 4,5,6 will be used as independent variables/terms/predictors.\n" ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# responses_num = map ( int , argv [ 0 ] . split ( ',' ) ) #NEWLINE# predictors_num = map ( int , argv [ 1 ] . split ( ',' ) ) #NEWLINE# fields = cvsfile . fieldnames #NEWLINE# responses_label = map ( ( lambda x : ( 'res.' + fields [ x ] ) ) , responses_num ) #NEWLINE# predictors_label = map ( ( lambda x : ( 'pre.' + fields [ x ] ) ) , predictors_num ) #NEWLINE# responses_name = map ( ( lambda x : fields [ x ] ) , responses_num ) #NEWLINE# predictors_name = map ( ( lambda x : fields [ x ] ) , predictors_num ) #NEWLINE# write_func ( ( '%s\t%s\n' % ( ',' . join ( map ( ( lambda x : str ( x ) ) , responses_name ) ) , ',' . join ( map ( ( lambda x : str ( x ) ) , predictors_name ) ) ) ) ) #NEWLINE# for l in cvsfile : #NEWLINE# #INDENT# t_str_list = [ ] #NEWLINE# for t in t_str_list : #NEWLINE# #INDENT# t_str_list . append ( l . setdefault ( t , 'NA' ) ) #NEWLINE# #UNINDENT# v_str_list = [ ] #NEWLINE# for v in predictors_name : #NEWLINE# #INDENT# v_str_list . append ( l . setdefault ( v , 'NA' ) ) #NEWLINE# #UNINDENT# write_func ( '\t' . join ( ( ',' . join ( t_str_list ) , ',' . join ( v_str_list ) ) ) ) #NEWLINE# write_func ( '\n' )