matrix - Reading multiple data files with a loop on Python -
hi have on 200 data files name similar names abc.20.0000.catalog.out , abc.20.1000.catalog.out, abc.20.2000.catalog.out ...... abc.40.0000.catalog.out
each file contains data
group catalog redshift 18.1000 1) group id 2) group mass (msun/h) 3- 5) initial position (mpc/h) 6- 8) final position (mpc/h) 9-11) velocity (km/s) 12) number of particles 250103187 0.227591e+08 1.86 1.03 2.51 1.65 1.06 2.53 -47.56 7.50 3.83 328 202456030 0.167918e+08 0.29 4.57 2.02 0.23 4.63 2.14 -13.27 10.67 3.68 242 89479147 0.763262e+06 1.47 4.80 0.89 1.34 4.83 0.99 -28.90 6.20 17.30 11
each such file contains on 10^6 lines.
i want following: 1. want read data each file , erase text on top. 2. want store data these files single big list of matrices, each matrix being data each of these files.
here python/pandas solution:
import pandas pd import glob l = [] f in glob.glob('abc*'): df = pd.read_csv(f,skiprows=1) l.append(df.values)
Comments
Post a Comment