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!

Merging data sets into one large data 1

Status
Not open for further replies.

mguha06

Technical User
Apr 20, 2006
28
US
I have a series of datasets called, fi.dat, f2.dat,f3.dat, etc.

Example of one of the dataset is given below:

f1.dat

A B C D E
F G H I
J K L

f2.dat

0.1 0.2. 0.4
A B C D
1 2 3 4


My final dataset should look like:

final.dat

A B C D E
F G H I
J K L
0.1 0.2. 0.4
A B C D
1 2 3 4



What's this means the values of f2.dat comes after the values of f1.dat and is written below f1.dat values.
Similarly, for f3.dat, f4.dat, etc.


Could someone please help me in this.

Thanks.
 
Hi

As far as I understand the problem :
Code:
awk 1 f*.dat > final.dat
But note that on Windows is possible to not get the files in order. So a better solution if you still use [tt]awk95[/tt] on Windows :
Code:
BEGIN {
  for (i=1;i<=3;i++) {
    while (getline < ("f" i ".dat")) print
    close ("f" i ".dat")
  }
}
( Please tell us in the future when the problem should be solved with [tt]awk95[/tt], while there are some minor incompatibilities. )

Feherke.
 
Hi Feherke,

Execellent! It works. It works the way I wanted. I always use awk95, I have a free version of awk95.exe.

I am giving you a star.
 
Why not simply this (if in DOS) ?
copy f1.dat+f2.dat final.dat

Or even this:
copy f*.dat final.dat

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi

I see you improved your DOS knowledges, since yesterday, PHV. :)
And of course there is abit more Unixish way too :
Code:
type f*.dat > phinal.dat
( Note, that is better to not have an output file name which match the input file wildcard. )

Feherke.
 
you improved your DOS knowledges
I love to learn ;-)
that is better to not have an output file name which match the input file wildcard
Good catch Feherke !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top