I have a data file in which the first line is made up of words. Here is the 
original data file:

#Column density-scaled with production rate 3.16227766016838e+25
-10.0000 0.000e+00  0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 
-9.9000 0.000e+00  0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 

I'd like to my program to skip any lines that begin with words and move on to 
lines that contain numbers. Right now I just cheat and delete the first line 
and resave the data file, but I was hoping that I could avoid these types of 
things in the future. Here is my code for reading the file and figuring out how 
many rows and columns to dimensionalize my array, then I read the data into the 
array:

from numpy import *
row=0
columnindex=0
x=open('halfmethanol.col','rt')
for line in x.readlines(): 
    data=line.split()
    columnindex=len(data)
    row=row+1
temp=ones((row,columnindex))
row=0
x=open('halfmethanol.col','rt')
for line in x.readlines():
    data=line.split()
    for column in range(columnindex):
        temp[row,column]=data[column]
    row=row+1

_________________________________________________________________
Windows Live™ SkyDrive™: Store, access, and share your photos. See how.
http://windowslive.com/Online/SkyDrive?ocid=TXT_TAGLM_WL_CS_SD_photos_072009
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to