#NEWLINE# def summary( cvsfile , write_func , * args ) : #NEWLINE# #INDENT# 'Show the column names.\n    ' #NEWLINE# fsnames = cvsfile . fieldnames #NEWLINE# data_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for f in fsnames : #NEWLINE# #INDENT# data_dict [ f ] = [ ] #NEWLINE# #UNINDENT# for l in cvsfile : #NEWLINE# #INDENT# for f in fsnames : #NEWLINE# #INDENT# v = l . setdefault ( f , None ) #NEWLINE# if ( v and ( v != 'NA' ) ) : #NEWLINE# #INDENT# data_dict [ f ] . append ( v ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# write_func ( 'colnum:colname\tsum,mean,median,std,cutoff\n' ) #NEWLINE# for ( i , f ) in enumerate ( fsnames ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# v_array = map ( float , fsnames [ f ] ) #NEWLINE# v_sum = ( '%.2f' % sum ( v_array ) ) #NEWLINE# v_mean = ( '%.2f' % mean ( v_array ) ) #NEWLINE# v_median = ( '%.2f' % median ( v_array ) ) #NEWLINE# v_std = ( '%.2f' % std ( v_array , float ( v_mean ) ) ) #NEWLINE# v_cutoff = ( '%.2f' % ( float ( v_mean ) + float ( v_std ) ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# ( v_sum , v_mean , v_median , v_std , v_cutoff ) = ( [ 'NA' ] * 5 ) #NEWLINE# #UNINDENT# write_func ( ( '%d:%s\t%s,%s,%s,%s,%s\n' % ( i , f , v_sum , v_mean , v_median , v_std , v_cutoff ) ) )