pseudocode - Understanding pseudo-code for Python implementation -


i given pseudo-code written no longer around question. told need implement in python. @ point not looking write code in python me, trying understand pseudo-code can write in python.

statsout = open('/shared/succedentsupercedent_stats','w') supercedents = tuple(open('/path', 'r')) succedents = tuple(open('abcd_.raw', 'r'))  ( cols = 1 succedents.columns , colg = 1 supercedents.columns )    /**** load users 1 succedent/supercedent array future stats   xy_array = new array ( supercedents.rows , 2 )   ( user = 1 supercedents.rows )     if succedents[user,cols].isvaliddouble , supercedents[user,colg].isvaliddouble               xy_array [ user , 1 ] = succedents[user,cols].todouble         xy_array [ user , 2 ] = supercedents[user,colg].todouble       enddo     endif   endfor    /*** stats 1 succedent:supercedent key users     sumx = sum( of xy_array[1:supercedents.rows][1]     sumy = sum( of xy_array[1:supercedents.rows][2]    /*** output succedent,supercedent,sumx,sumy     append(statsout,succedent,supercedent,sumx,sumy) endfor         

if can shed light on interpret doing hugely helpful me.

here guess required pseudo-code. not entirely clear required, , @ actual data being read , sample of produced helpful. without sample input , output, difficult figure out code supposed accomplish.

def main():     succedents = load_succedents('abcd_reddob_cases.raw')     supercedents = load_supercedents('/shared/voom_e_plink_cases')     open('/shared/succedentsupercedent_stats', 'w') stats_out:         cols in range(len(succedents[0])):             colg in range(len(supercedents[0])):                 xy_array = [[0] * 2 _ in range(len(supercedents))]                 user in range(len(supercedents)):                     s1, s2 = succedents[user][cols], supercedents[user][colg]                     if is_valid_double(s1) , is_valid_double(s2):                         xy_array[user] = to_double(s1), to_double(d2)                 sumx = sum(row[0] row in xy_array)                 sumy = sum(row[1] row in xy_array)                 append(stats_out, cols, colg, sumx, sumy)  def load_supercedents(path):     open(path) file:         # perform whatever need loading supercedents         # sort of data conversion may need take place here         supercedents = tuple(file)     return supercedents  def load_succedents(path):     open(path) file:         # perform whatever need loading succedents         # sort of data conversion may need take place here         succedents = tuple(file)     return succedents  def is_valid_double(data):     # determine if data valid double or not     return true or false  def to_double(data):     # convert data whatever double happens     return data  def append(file, s, g, x, y):     # write data file     print('cols = {s}, colg = {g}, sumx = {x}, sumy = {y}'.format(**locals()),           file=file, flush=true)  if __name__ == '__main__':     main() 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -