Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manipulate files 1

Status
Not open for further replies.

tonivm

Technical User
Mar 2, 2006
64
ES
Hi everybody:

I have a problem. I have a output files which have this pattern:

number1
--space
block1a - 7rows/10columns/65elements
--space
block1b - 7rows/10columns/65elements
--space
block1c - 7rows/10columns/65elements
--space
number2
--space
block2a - 7rows/10columns/65elements
--space
block2b - 7rows/10columns/65elements
--space
block2c - 7rows/10columns/65elements
--space
.....

Actually is like:

3.00000000

1.000E+02 6.549E+01 4.252E+01 2.755E+01 1.786E+01 1.163E+01 7.660E+00 5.140E+00 3.550E+00 2.560E+00
1.950E+00 1.570E+00 1.330E+00 1.190E+00 1.100E+00 1.040E+00 1.010E+00 9.800E-01 9.600E-01 9.500E-01
9.300E-01 9.200E-01 9.100E-01 9.000E-01 8.900E-01 8.800E-01 8.700E-01 8.600E-01 8.500E-01 8.400E-01
8.300E-01 8.200E-01 8.100E-01 8.000E-01 7.900E-01 7.800E-01 7.700E-01 7.600E-01 7.500E-01 7.400E-01
7.300E-01 7.200E-01 7.100E-01 7.000E-01 6.900E-01 6.800E-01 6.700E-01 6.600E-01 6.500E-01 6.400E-01
6.300E-01 6.200E-01 6.100E-01 6.000E-01 5.900E-01 5.800E-01 5.700E-01 5.600E-01 5.500E-01 5.400E-01
5.300E-01 5.200E-01 5.100E-01 5.000E-01 4.900E-01

3.716E-01 3.716E-01 3.716E-01 3.713E-01 3.692E-01 3.651E-01 3.481E-01 3.163E-01 2.820E-01 2.564E-01
2.300E-01 2.067E-01 1.921E-01 1.834E-01 1.780E-01 1.745E-01 1.728E-01 1.711E-01 1.699E-01 1.694E-01
1.682E-01 1.677E-01 1.671E-01 1.665E-01 1.660E-01 1.654E-01 1.648E-01 1.643E-01 1.637E-01 1.631E-01
1.626E-01 1.620E-01 1.614E-01 1.609E-01 1.603E-01 1.598E-01 1.592E-01 1.586E-01 1.581E-01 1.575E-01
1.570E-01 1.564E-01 1.559E-01 1.553E-01 1.547E-01 1.542E-01 1.536E-01 1.530E-01 1.525E-01 1.519E-01
1.513E-01 1.507E-01 1.501E-01 1.496E-01 1.490E-01 1.484E-01 1.478E-01 1.472E-01 1.467E-01 1.461E-01
1.455E-01 1.449E-01 1.442E-01 1.436E-01 1.430E-01

-1.348E-11 1.111E-08 2.743E-06 9.164E-05 7.046E-04 1.189E-03 1.450E-03 1.596E-03 1.759E-03 1.999E-03
2.188E-03 2.300E-03 2.390E-03 2.448E-03 2.488E-03 2.517E-03 2.531E-03 2.546E-03 2.556E-03 2.561E-03
2.572E-03 2.578E-03 2.583E-03 2.589E-03 2.594E-03 2.600E-03 2.606E-03 2.611E-03 2.617E-03 2.623E-03
2.629E-03 2.634E-03 2.639E-03 2.644E-03 2.649E-03 2.654E-03 2.659E-03 2.664E-03 2.668E-03 2.673E-03
2.678E-03 2.683E-03 2.688E-03 2.693E-03 2.699E-03 2.704E-03 2.709E-03 2.715E-03 2.720E-03 2.726E-03
2.731E-03 2.737E-03 2.742E-03 2.747E-03 2.752E-03 2.756E-03 2.761E-03 2.765E-03 2.770E-03 2.775E-03
2.780E-03 2.784E-03 2.788E-03 2.789E-03 2.786E-03

3.716E-01 3.716E-01 3.716E-01 3.713E-01 3.699E-01 3.663E-01 3.495E-01 3.179E-01 2.837E-01 2.584E-01
2.322E-01 2.090E-01 1.945E-01 1.859E-01 1.805E-01 1.770E-01 1.753E-01 1.736E-01 1.725E-01 1.719E-01
1.708E-01 1.703E-01 1.697E-01 1.691E-01 1.686E-01 1.680E-01 1.674E-01 1.669E-01 1.663E-01 1.658E-01
1.652E-01 1.646E-01 1.641E-01 1.635E-01 1.630E-01 1.624E-01 1.619E-01 1.613E-01 1.608E-01 1.602E-01
1.596E-01 1.591E-01 1.585E-01 1.580E-01 1.574E-01 1.569E-01 1.563E-01 1.557E-01 1.552E-01 1.546E-01
1.540E-01 1.535E-01 1.529E-01 1.523E-01 1.517E-01 1.512E-01 1.506E-01 1.500E-01 1.494E-01 1.488E-01
1.483E-01 1.477E-01 1.470E-01 1.464E-01 1.458E-01

8.763E-04 8.763E-04 8.761E-04 8.711E-04 8.370E-04 8.114E-04 8.184E-04 8.588E-04 9.081E-04 9.440E-04
9.894E-04 1.043E-03 1.075E-03 1.091E-03 1.098E-03 1.102E-03 1.103E-03 1.104E-03 1.105E-03 1.105E-03
1.105E-03 1.105E-03 1.104E-03 1.104E-03 1.104E-03 1.103E-03 1.102E-03 1.101E-03 1.100E-03 1.098E-03
1.096E-03 1.095E-03 1.093E-03 1.092E-03 1.091E-03 1.089E-03 1.088E-03 1.087E-03 1.086E-03 1.085E-03
1.084E-03 1.082E-03 1.081E-03 1.079E-03 1.078E-03 1.076E-03 1.073E-03 1.071E-03 1.068E-03 1.065E-03
1.061E-03 1.057E-03 1.053E-03 1.049E-03 1.045E-03 1.041E-03 1.036E-03 1.031E-03 1.025E-03 1.018E-03
1.010E-03 1.001E-03 9.913E-04 9.801E-04 9.742E-04


3.03020728

1.000E+02 6.549E+01 4.252E+01 2.755E+01 1.786E+01 1.163E+01 7.660E+00 5.140E+00 3.550E+00 2.560E+00
1.950E+00 1.570E+00 1.330E+00 1.190E+00 1.100E+00 1.040E+00 1.010E+00 9.800E-01 9.600E-01 9.500E-01
9.300E-01 9.200E-01 9.100E-01 9.000E-01 8.900E-01 8.800E-01 8.700E-01 8.600E-01 8.500E-01 8.400E-01
8.300E-01 8.200E-01 8.100E-01 8.000E-01 7.900E-01 7.800E-01 7.700E-01 7.600E-01 7.500E-01 7.400E-01
7.300E-01 7.200E-01 7.100E-01 7.000E-01 6.900E-01 6.800E-01 6.700E-01 6.600E-01 6.500E-01 6.400E-01
6.300E-01 6.200E-01 6.100E-01 6.000E-01 5.900E-01 5.800E-01 5.700E-01 5.600E-01 5.500E-01 5.400E-01
5.300E-01 5.200E-01 5.100E-01 5.000E-01 4.900E-01

7.256E-01 7.256E-01 7.256E-01 7.251E-01 7.215E-01 7.134E-01 6.706E-01 5.905E-01 5.069E-01 4.470E-01
3.875E-01 3.365E-01 3.056E-01 2.877E-01 2.767E-01 2.696E-01 2.661E-01 2.627E-01 2.604E-01 2.593E-01
2.570E-01 2.559E-01 2.548E-01 2.537E-01 2.525E-01 2.514E-01 2.503E-01 2.492E-01 2.481E-01 2.469E-01
2.458E-01 2.447E-01 2.436E-01 2.425E-01 2.414E-01 2.403E-01 2.392E-01 2.381E-01 2.370E-01 2.360E-01
2.349E-01 2.338E-01 2.327E-01 2.316E-01 2.305E-01 2.294E-01 2.284E-01 2.273E-01 2.262E-01 2.250E-01
2.239E-01 2.228E-01 2.217E-01 2.206E-01 2.195E-01 2.184E-01 2.173E-01 2.162E-01 2.151E-01 2.140E-01
2.128E-01 2.117E-01 2.105E-01 2.092E-01 2.081E-01

-1.831E-11 2.366E-08 5.964E-06 1.998E-04 1.539E-03 2.594E-03 3.112E-03 3.342E-03 3.604E-03 4.017E-03
4.295E-03 4.441E-03 4.574E-03 4.664E-03 4.729E-03 4.775E-03 4.799E-03 4.822E-03 4.839E-03 4.847E-03
4.865E-03 4.875E-03 4.885E-03 4.894E-03 4.904E-03 4.914E-03 4.924E-03 4.933E-03 4.943E-03 4.953E-03
4.962E-03 4.971E-03 4.979E-03 4.986E-03 4.992E-03 4.999E-03 5.006E-03 5.012E-03 5.018E-03 5.025E-03
5.031E-03 5.038E-03 5.046E-03 5.054E-03 5.062E-03 5.071E-03 5.080E-03 5.088E-03 5.097E-03 5.106E-03
5.115E-03 5.124E-03 5.132E-03 5.138E-03 5.143E-03 5.148E-03 5.152E-03 5.158E-03 5.165E-03 5.172E-03
5.179E-03 5.184E-03 5.186E-03 5.183E-03 5.161E-03

7.256E-01 7.256E-01 7.256E-01 7.253E-01 7.231E-01 7.160E-01 6.737E-01 5.938E-01 5.105E-01 4.511E-01
3.918E-01 3.409E-01 3.102E-01 2.924E-01 2.814E-01 2.744E-01 2.709E-01 2.675E-01 2.653E-01 2.641E-01
2.619E-01 2.608E-01 2.597E-01 2.586E-01 2.574E-01 2.563E-01 2.552E-01 2.541E-01 2.530E-01 2.519E-01
2.508E-01 2.497E-01 2.486E-01 2.475E-01 2.464E-01 2.453E-01 2.442E-01 2.431E-01 2.421E-01 2.410E-01
2.399E-01 2.388E-01 2.378E-01 2.367E-01 2.356E-01 2.345E-01 2.334E-01 2.323E-01 2.312E-01 2.302E-01
2.291E-01 2.279E-01 2.268E-01 2.257E-01 2.246E-01 2.235E-01 2.224E-01 2.213E-01 2.202E-01 2.191E-01
2.180E-01 2.169E-01 2.157E-01 2.144E-01 2.133E-01

1.758E-03 1.758E-03 1.757E-03 1.746E-03 1.667E-03 1.607E-03 1.626E-03 1.731E-03 1.875E-03 1.996E-03
2.128E-03 2.277E-03 2.370E-03 2.418E-03 2.441E-03 2.454E-03 2.458E-03 2.463E-03 2.467E-03 2.469E-03
2.471E-03 2.471E-03 2.471E-03 2.471E-03 2.470E-03 2.469E-03 2.467E-03 2.465E-03 2.463E-03 2.459E-03
2.455E-03 2.451E-03 2.447E-03 2.444E-03 2.442E-03 2.439E-03 2.436E-03 2.433E-03 2.431E-03 2.430E-03
2.428E-03 2.426E-03 2.424E-03 2.421E-03 2.417E-03 2.413E-03 2.409E-03 2.404E-03 2.398E-03 2.391E-03
2.384E-03 2.374E-03 2.364E-03 2.354E-03 2.345E-03 2.336E-03 2.326E-03 2.314E-03 2.300E-03 2.282E-03
2.261E-03 2.235E-03 2.205E-03 2.168E-03 2.148E-03
....
..

Where block1a, block2a ... are the same.

Then I would like to create a file like this:

number1 block1b
number2 block2b
number3 block3b
....
..

I guess that each block should be saved as string.
Could anybody give any solution.
Thanks in advance.
Edit/Delete Message
 
Could anybody give any solution
What have YOU tried so far and where in YOUR code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry:
But I think that the question coulb be more simple.
Each block at the end of line manually I have seen that with one "supr" the next line becomes in the same than previous. Then I would like to know how I can eliminate the final carriage return that there is in each line.
Thanks. :D
 
Each block at the end of line manually I have seen that with one "supr" the next line becomes in the same than previous.
Are we supposed to understand this???
 
I would like to know how I can delete the carriage return of each line in each block. :D
 
to join lines: concatenate the variable $0 in another variable, then whan you have enough, or some criterium is met; print the variable

for instance: join all lines that have 5 or more fields
then, if empty line, print out the joined lines and reiterate

Try this:

if ($NF >= 5) {var=var " " $0}
if ($NF == 0) {print var; var=""}


HTH,

p5wizard
 
Hi

p5wizard, that code sample must be the most messed up one you ever posted. ;-)
Code:
[s][red]if[/red][/s] ([s][red]$[/red][/s]NF >= 5) {var=var " " $0}
[s][red]if[/red][/s] ([s][red]$[/red][/s]NF == 0) {print var; var=""}

Feherke.
 
Feherke, I must have temporarily switched off my awk-brain

how awkward...

inside an awk program block , the "if"s shouldn't go though

p5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top