Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24505

[newbie] problem with data (different behaviour between batch and interactive use)

From Jean Dupont <jeandupont115@gmail.com>
Newsgroups comp.lang.python
Subject [newbie] problem with data (different behaviour between batch and interactive use)
Date 2012-06-27 05:24 -0700
Organization http://groups.google.com
Message-ID <aec77bb0-7d2f-43f7-a556-3a59ad016112@googlegroups.com> (permalink)

Show all headers | View raw


I have some data which is presented in the following format to me:
+3.874693E-01,+9.999889E-03,+9.910000E+37,+1.876595E+04,+3.994000E+04
I'm only interested in the first two fields i.e.
+3.874693E-01,+9.999889E-03
If I start python interactively I can separate the fields as follows:
>measurement=+3.874693E01,+9.999889E03,+9.910000E+37,+1.876595E+04,+3.994000E+04
>print measurement[0]
0.3874693
>print measurement[1]
0.009999889
If however I run a script with the same commands I get something different:
The script does this:
measurement=serkeith.readline().replace('\x11','').replace('\x13','').replace('\x0d','\n')
print measurement[0]
+
print measurement[1]
3

can anyone here tell me what I'm doing wrong and how to do it correctly

thanks
jean

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[newbie] problem with data (different behaviour between batch and interactive use) Jean Dupont <jeandupont115@gmail.com> - 2012-06-27 05:24 -0700
  Re: [newbie] problem with data (different behaviour between batch and interactive use) Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-06-27 15:46 +0300
  Re: [newbie] problem with data (different behaviour between batch and interactive use) Cousin Stanley <cousinstanley@gmail.com> - 2012-06-27 13:23 +0000
  Re: [newbie] problem with data (different behaviour between batch and interactive use) Justin Barber <barber.justin@gmail.com> - 2012-06-27 07:09 -0700

csiph-web