[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Please help parsing file [sed, awk, fortran, bash]



daniel jimenez apparently described a *HOMEWORK* problem:
Hello all,

I need some help fixing the format of some pretty strangely
compressed data files. An example would be like this:

2883
452
07
16
2
4
6
107

Parsing rules:
The first two lines should be ignored.
The first column is the 'index', the second column being the
'counter'.
If there is no second number (ex. index=2), then the second
number should be set to '1'.
If there the index skips (ex. from index=2 to index=4), then
the indexes which where skipped should be set to '0'
Max index is 1024.

That is it. I'd like to be guided to an app (scripting
language? awk? sed? I haven't used those so I really don't
know where to start) that can help me do that effectively.

The command, with the script possibly as the argument, is to
be included in a bash script right before a fortran program
is executed as the fortran program expects the file to be
uncompressed and it doesn't seem intuitive to do it from
fortran. Although it would be nice for a guru to let me know
how to handle it from within...

In the end, any solution would be a great help.

Thanks.

--
Daniel Jiménez

Back when all computers used ONLY vacuum tubes, we freshman EE's had a saying,
"If all else fails - THIMK"

2nd hint - you've already stated the solution
3rd hint - I believe answer could be coded in less than a dozen lines of Lawrence Livermore BASIC 4th hint - Have You thought about a vector as opposed to a multidimensional array?

Bonus question - Why did I immediately think pseudo code?

HTH





Reply to: