Thanks a lot. That works for me.
Chris Rebert-6 wrote: > > On Mon, Jun 1, 2009 at 11:45 AM, babypython <2myemailaddr...@gmail.com> > wrote: >> >> I am trying to parse through this data for analysis. I am new to python >> and >> wondering what would be the quickest way to extract the data from this >> file. >> The data files consists of comments (starting with ! and #). Then, the >> data >> follows. All I want is the data in array ( I don't care about the >> comments),and the data format is freq[], s11[real], s11[imag], >> s21[real],s21[imag] >> >> Any help will be appreciated. Thanks. >> >> >> !Date: Jan 29, 2008 14:40:26 >> !Correction: S11(Full 2 Port(1,2)) S21(Full 2 Port(1,2)) >> !Measurements: S11, S21: >> ! Freq S11[real, imag] S21[real,imag] >> 1400000000 -2.104572e+001 4.153887e+001 -4.084314e+001 8.417739e+001 >> 1400250000 -2.089971e+001 4.028599e+001 -4.087196e+001 7.026196e+001 >> 1400500000 -2.114216e+001 4.086434e+001 -4.055134e+001 6.559201e+001 >> 1400750000 -2.112057e+001 3.681709e+001 -4.024515e+001 5.503412e+001 >> 1401000000 -2.110984e+001 3.622524e+001 -4.056519e+001 5.162795e+001 >> 1401250000 -2.123562e+001 3.602308e+001 -4.125660e+001 4.330296e+001 >> 1401500000 -2.152193e+001 3.345480e+001 -4.035107e+001 3.937940e+001 >> 1401750000 -2.144410e+001 3.189340e+001 -4.097492e+001 2.802726e+001 >> 1402000000 -2.155891e+001 3.002732e+001 -4.146297e+001 1.666007e+001 >> 1402250000 -2.170474e+001 2.896428e+001 -4.146934e+001 1.514847e+001 >> 1402500000 -2.185459e+001 2.863795e+001 -4.053018e+001 1.130192e+001 > > #completely untested > data = [] > for line in the_file: > if line.startswith("!"): continue > fields = line.strip().split() > datapoint = [int(fields[0]), complex(float(fields[1]), > float(fields[2])), complex(float(fields[3]), float(fields[4]))] > data.append(datapoint) > > Cheers, > Chris > -- > http://blog.rebertia.com > -- > http://mail.python.org/mailman/listinfo/python-list > > -- View this message in context: http://www.nabble.com/Parsing-Data-tp23820003p23821445.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list