Modify output data file

Dear all,

I am a beginner and I hope you can help. I need to convert an output data file, made of a 5-line header, 3 columns, and 300 rows. The first column contains an index from 1 to 40, the second and third columns are floating numbers.
Example:
#comments line 1
#2
#3
#4
#5
1 -145.5 0.87643
1 -142.5 0.67890
: : :
1 145.5 0.56784
2 -145.5 0.54334
2 -142.5 0.67894
: : :
3 : :
3 : :
3 : :
4 : :
4
4
::
40 : :

I'd like to write a new data file, ignoring the first 5 lines of comments. The new files must have the first three columns corresponding to index 1, and additional columns containing the entries corresponding to indexes 2 to 40.
Something like that:

1 -142.5 0.89854 2 -142.5 0.56788 : : : : : : : : : : : : : : : : 40 -142.5 0.7438
1 145.5 0.678854 2 -140 0.546356 :::::::::::::::::::::::::::::: 40 154 0.64784

Is anyone able to help?

Thank you so much in advance!
Jenxx
What, specifically, is the problem you're having doing this? What have you tried so far?
is this a coding exercise or a need? If you just need the result, this looks like something you could do easier in notepad++. If you want to code it (or need to, if you had a lot of the files to do) ... as said, what have you done so far?

the basic algorithm would be
read and ignore 5 lines
then you could do it really simply by reading all the rest of it into a big chunk and doing a replace of end of lines (figure out which types you have in the file or do them all) with nothing; consider remove_if()

Thank you, it is a need, and I'll follow your advice and do it in notepad++.

Thanks!
I said N++ because its search and replace can do powerful things like regx, and it also understands C like entries, eg you can enable escape codes in the replace menu and replace all the end of lines by just doing
replace
\r (or \n) or combos of \r\n etc
with
nothing

its that easy :)

it also supports the old visual studio style macros and alt+drag to cut square chunks of text.

you can do it with any of many other tools, this is just one free suggestion
Last edited on
Topic archived. No new replies allowed.