Search for a row with a pattern in a column

Hi,

I am trying to "grep" in 650 data files a row which has a particular
number on column 2, namely " 0.250000000000000E+00 ".

Alternatively, I could look for that row by searching for the first
column, which is " 1 ".

Unfortunately, this row changes position in the 650 files and looks like this:

···

-----------
.
.
.
     4224 0.249999993684469E-04 0.450621747970581E+01
-0.217168951034546E+01 0.798277109861374E-01 -0.598546504974365E+00
-0.947211563587189E+00 0.298483103513718E+00 0.694457411766052E+00
-0.135573709011078E+01 0.500285959243774E+01 0
      4225 0.249999993684469E-04 0.503941202163696E+01
-0.236623978614807E+01 -0.171467363834381E+00 -0.204598993062973E+00
-0.764434099197388E+00 0.354671090841293E+00 0.141895398497581E+00
-0.693929433822632E+00 0.556993389129639E+01 0
      4226 0.249999993684469E-04 0.403050041198730E+01
-0.215032029151917E+01 0.877652913331985E-01 -0.991083562374115E+00
0.611193120479584E+00 0.273028463125229E+00 0.364663577079773E+01
-0.221709823608398E+01 0.456908226013184E+01 0
         1 0.250000000000000E+00 0.417827463150024E+01
-0.208329892158508E+01 0.104015089571476E+00 0.154748081695288E-02
-0.619542039930820E-02 -0.361486850306392E-02 0.216096282005310E+01
-0.701378881931305E+00 0.467000341415405E+01 0
      4228 0.249999993684469E-04 -0.348412361145020E+02
-0.309311046600342E+02 -0.551393890380859E+01 -0.908447951078415E-01
-0.427876152098179E-01 -0.533953774720430E-02 0.295748591423035E+01
-0.196792855858803E-01 0.469153327941895E+02 0
      4229 0.249999993684469E-04 0.427954912185669E+01
-0.195016658306122E+01 0.785302296280861E-01 0.806781768798828E+00
-0.110497450828552E+01 -0.624167263507843E+00 0.235030865669250E+01
-0.216405773162842E+01 0.470360040664673E+01 0
      4230 0.249999993684469E-04 0.551125669479370E+01
-0.394835329055786E+01 0.588055849075317E+00 -0.504932820796967E+00
0.104279957711697E+00 -0.213553920388222E+00 0.198102459311485E+00
-0.341262459754944E+00 0.680509042739868E+01 0
.
.
.
-------------

The purpose is to identify the row and then plot the 3rd and 4th
columns once that row has been identified:

X_inst = FILE[???:, 2] # Column 3
Y_inst = FILE[???:, 3] # Column 4

My problem is how to define those ???

thanks a lot,

Pau

This is more of a numpy problem than a matplotlib problem. I would suggest asking on numpy’s mailing list.

Ben Root

···

On Thu, Apr 28, 2011 at 1:13 PM, Pau <vim.unix@…982…> wrote:

Hi,

I am trying to “grep” in 650 data files a row which has a particular

number on column 2, namely " 0.250000000000000E+00 ".

Alternatively, I could look for that row by searching for the first

column, which is " 1 ".

Unfortunately, this row changes position in the 650 files and looks like this:


.

.

.

 4224  0.249999993684469E-04  0.450621747970581E+01

-0.217168951034546E+01 0.798277109861374E-01 -0.598546504974365E+00

-0.947211563587189E+00 0.298483103513718E+00 0.694457411766052E+00

-0.135573709011078E+01 0.500285959243774E+01 0

  4225  0.249999993684469E-04  0.503941202163696E+01

-0.236623978614807E+01 -0.171467363834381E+00 -0.204598993062973E+00

-0.764434099197388E+00 0.354671090841293E+00 0.141895398497581E+00

-0.693929433822632E+00 0.556993389129639E+01 0

  4226  0.249999993684469E-04  0.403050041198730E+01

-0.215032029151917E+01 0.877652913331985E-01 -0.991083562374115E+00

0.611193120479584E+00 0.273028463125229E+00 0.364663577079773E+01

-0.221709823608398E+01 0.456908226013184E+01 0

     1  0.250000000000000E+00  0.417827463150024E+01

-0.208329892158508E+01 0.104015089571476E+00 0.154748081695288E-02

-0.619542039930820E-02 -0.361486850306392E-02 0.216096282005310E+01

-0.701378881931305E+00 0.467000341415405E+01 0

  4228  0.249999993684469E-04 -0.348412361145020E+02

-0.309311046600342E+02 -0.551393890380859E+01 -0.908447951078415E-01

-0.427876152098179E-01 -0.533953774720430E-02 0.295748591423035E+01

-0.196792855858803E-01 0.469153327941895E+02 0

  4229  0.249999993684469E-04  0.427954912185669E+01

-0.195016658306122E+01 0.785302296280861E-01 0.806781768798828E+00

-0.110497450828552E+01 -0.624167263507843E+00 0.235030865669250E+01

-0.216405773162842E+01 0.470360040664673E+01 0

  4230  0.249999993684469E-04  0.551125669479370E+01

-0.394835329055786E+01 0.588055849075317E+00 -0.504932820796967E+00

0.104279957711697E+00 -0.213553920388222E+00 0.198102459311485E+00

-0.341262459754944E+00 0.680509042739868E+01 0

.

.

.


The purpose is to identify the row and then plot the 3rd and 4th

columns once that row has been identified:

X_inst = FILE[???:, 2] # Column 3

Y_inst = FILE[???:, 3] # Column 4

My problem is how to define those ???

thanks a lot,

Pau