Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79269
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder1.news.weretis.net!news.roellig-ltd.de!open-news-network.org!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!freenix!jussieu.fr!not-for-mail |
|---|---|
| From | Alain Ketterlin <alain@dpt-info.u-strasbg.fr> |
| Newsgroups | comp.lang.python |
| Subject | Re: your mail |
| Date | Sat, 18 Oct 2014 13:15:56 +0200 |
| Organization | Universites Paris VI/Paris VII - France |
| Lines | 33 |
| Message-ID | <87ppdp39xv.fsf@dpt-info.u-strasbg.fr> (permalink) |
| References | <CAPxp-0Txqk-cWcpa=2uMQ6cwS57gnQU4xrjp+jO4y+Vn3kR1mQ@mail.gmail.com> <20141017104316.GA49644@cskk.homeip.net> <mailman.14947.1413563848.18130.python-list@python.org> |
| NNTP-Posting-Host | icps-laptop-ketterlin.u-strasbg.fr |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | vishnu.jussieu.fr 1413630956 79169 130.79.192.170 (18 Oct 2014 11:15:56 GMT) |
| X-Complaints-To | usenet@vishnu.jussieu.fr |
| NNTP-Posting-Date | Sat, 18 Oct 2014 11:15:56 +0000 (UTC) |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
| Cancel-Lock | sha1:O3QaYFnAryG0ntpfTlpkbP2Du4g= |
| Xref | csiph.com comp.lang.python:79269 |
Show key headers only | View raw
Terry Reedy <tjreedy@udel.edu> writes:
> On 10/17/2014 6:43 AM, Cameron Simpson wrote:
>> On 17Oct2014 11:45, Dhananjay <dhananjay.c.joshi@gmail.com> wrote:
>
>>> 2.1576318858 -1.8651195165 4.2333428278
>>> ...
>>> (total of 200 lines)
>>>
>>> Columns 1,2,3 corresponds to x,y,z axis data points.
>
>> for line in open('flooding-psiphi.dat','r'):
>> line = line.split()
>> xs.append(float(line[0]))
>> ys.append(float(line[1]))
>> zs.append(float(line[2]))
>
> A further refinement:
> for line in open('flooding-psiphi.dat','r'):
> x, y, z = map(float, line.split())
> xs.append(x)
> ys.append(y)
> zs.append(z)
Or even:
xs,ys,zs = zip(*[ map(float,line.split())
for line in open('flooding-psiphi.dat','r') ])
You get tuples, though. Use map(list,zip(...)) if you need lists. Easy
to update when you move to 4D data...
-- Alain.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: your mail Terry Reedy <tjreedy@udel.edu> - 2014-10-17 12:37 -0400
Re: your mail Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-10-18 13:15 +0200
Re: your mail Peter Otten <__peter__@web.de> - 2014-10-18 15:03 +0200
csiph-web