Python ASCII Reading tables -
i'm sorry asking silly question have spend half day , not find reasonable solution. have ascii file:
"x" "z" "y" 285807.2 -1671.056 2405.91 285807.2 -1651.162 2394.932 285807.2 -1631.269 2383.962 285807.2 -1611.375 2372.988 285807.2 -1591.481 2362.01 285807.2 -1571.587 2351.01
............................................. ~1 000 000 rows
and normaly read it:
from astropy.io import ascii data =ascii.read('c:\\users\\protoss\\desktop\\ishodnik1.dat') print (data)
but how deal columns? instance sum each rows or make average value, etc columns z , y? understand have converts date list of float valuse except headliner , write new ascii file, doesn't it?
what did. separated columns , added different lists. have got access different columns:
import numpy np open('c:\\users\\protoss\\desktop\\ishodnik.dat' ,'r') f: header1 = f.readline() x_list=[] z_list=[] v_list=[] line in f: line = line.strip() columns = line.split() x = (float(columns[0])) z = (float(columns[1])) v = (float(columns[2])) x_list.append(x) z_list.append(z) v_list.append(v)
Comments
Post a Comment