Merging Three simple Text files

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Merging Three simple Text files

Post by I_Server_Whale »

Hi All,

What is the best way to merge three sequential files?
All three sequential files have just one same field with same length.

I also need to purge these three files after they are merged into one.

I thought about having three sequential file stages one after the other with transformers in between and final sequential stage which has the merged data.

Another idea was using a merge stage. Can I use Merge Stage to merge three files into one?

And I'm thinking of using an 'After job subroutine' which calls a batch file
to purge these three input files.

Any suggestions or other ideas are very much welcome,

Thanks much,

Naveen.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi NaveenD,

Why dont you use a simple batch script and call it in the before stage?. The batch script can be something like this

Code: Select all

type file1.txt file2.txt file3.txt > bigfile.txt
del /Q file*.txt
If your standardize the file names, it will be much simpler to make use of the wildcards in your batch script.
Thanks,
Naveen
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Hi pnchowdary,

Thanks for your response. What is the " /Q" for in the command you sent?

Also, I have to put a date and timestamp into the BIGFILE name. I'm currently doing this using datastage. I'm not sure whether the same can be achieved using DOS script.

Is there any command in DOS which just clears the file instead of deleting it?

Please let me know. Thanks a lot,

Naveen.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

the output of "DEL /?" Gives us:

Code: Select all

C:\Documents and Settings\guest3>del /?
Deletes one or more files.

DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

  names         Specifies a list of one or more files or directories.
                Wildcards may be used to delete multiple files. If a
                directory is specified, all files within the directory
                will be deleted.

  /P            Prompts for confirmation before deleting each file.
  /F            Force deleting of read-only files.
  /S            Delete specified files from all subdirectories.
  /Q            Quiet mode, do not ask if ok to delete on global wildcard
  /A            Selects files to delete based on attributes
  attributes    R  Read-only files            S  System files
                H  Hidden files               A  Files ready for archiving
                -  Prefix meaning not

If Command Extensions are enabled DEL and ERASE change as follows:

The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi NaveenD,

As Arndw already pointed out. /Q switch in Del command, suppresses the confirmation message when deleting mutliple files using wildcards.
Thanks,
Naveen
ketfos
Participant
Posts: 562
Joined: Mon May 03, 2004 8:58 pm
Location: san francisco
Contact:

Post by ketfos »

Hi,
For adding the date you can use the following in Unix

type file1.txt file2.txt file3.txt > bigfile`date +"%Y%m%d"`.txt

This will give output like bigfile20050824.txt

Ketfos
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

The req is in Win.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Create the target file using a generic name then use an after-stage subroutine like this one to change the file name.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply