On Feb 23, 4:06 pm, Tim Chase <python.l...@tim.thechases.com> wrote: > > I would like to read a text file of numbers produced by a data > > acquisition system into three vectors of doubles. The contents of the > > file are: > > > +0.0000000e+0 +2.7645134e+1 +2.7745625e+1 > > +0.4100041e-1 +2.7637787e+1 +2.7731047e+1 > > +0.0820008e+0 +2.7645134e+1 +2.7750483e+1 > > ... > > > or > > > +0.0000000e+0\t+2.7645134e+1\t+2.7745625e+1\r\n > > ... > > > I would like to read the first column into time_vec, second into > > ch1_vec and so on. > > > (I have never programmed in python and am having trouble finding a way > > to do this). > > Well, a very terse way of doing it would be something like: > > time_vec, ch1_vec, and_so_on = zip(*( > map(float, line.split()) > for line in file('in.txt'))) > > If my junior developer authored that, I'm not sure whether I'd > laud her or fire her. :) > > If this isn't homework, there are some less terse versions which > are a bit easier on the eyes and less like some love-child > between Perl and Python. > > -tkc
haha, no this isn't homework. I'm a mechanical engineering student working on a research project and this program is for my personal use to analyze the data. -- http://mail.python.org/mailman/listinfo/python-list