python - averaging only second column data from multiple files -


i have total 64 files each file name below:

diffusion-isomalto-thermo1.dat_x.xmgr diffusion-isomalto-thermo2.dat_x.xmgr diffusion-isomalto-thermo3.dat_x.xmgr diffusion-isomalto-thermo4.dat_x.xmgr . . diffusion-isomalto-thermo64.dat_x.xmgr 

each file contains 2 columns of data in format:

 5.000     1.047 10.000     1.107 15.000     1.211 20.000     1.083 25.000     1.166 30.000     1.368 35.000     1.179 40.000     1.307 45.000     0.985 50.000     0.954 

containing 50,000 lines of data.

what want average of first row second column files (64 files) , next average second row second column on files.

what approach this?

with gnu awk:

awk 'fnr==1{a+=$2;next}{b+=$2;close(filename);nextfile}end{print a,b}' diffusion* 

assuming globbing of diffusion* picks 64 files want. if not use stricter diffusion-isomalto-thermo*.dat_x.xmgr.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -