Text Processing
Nick Dokos
nicholas.dokos at hp.com
Tue Dec 20 16:04:45 EST 2011
Jérôme <jerome at jolimont.fr> wrote:
> Tue, 20 Dec 2011 11:17:15 -0800 (PST)
> Yigit Turgut a écrit:
>
> > Hi all,
> >
> > I have a text file containing such data ;
> >
> > A B C
> > -------------------------------------------------------
> > -2.0100e-01 8.000e-02 8.000e-05
> > -2.0000e-01 0.000e+00 4.800e-04
> > -1.9900e-01 4.000e-02 1.600e-04
> >
> > But I only need Section B, and I need to change the notation to ;
> >
> > 8.000e-02 = 0.08
> > 0.000e+00 = 0.00
> > 4.000e-02 = 0.04
> >
> > Text file is approximately 10MB in size. I looked around to see if
> > there is a quick and dirty workaround but there are lots of modules,
> > lots of options.. I am confused.
> >
> > Which module is most suitable for this task ?
>
> You could try to do it yourself.
>
Does it have to be python? If not, I'd go with something similar to
sed 1,2d foo.data | awk '{printf("%.2f\n", $2);}'
Nick
More information about the Python-list
mailing list