Page 1 of 1

Merging Three simple Text files

Posted: Wed Aug 24, 2005 8:30 am
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.

Posted: Wed Aug 24, 2005 8:41 am
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.

Posted: Wed Aug 24, 2005 9:06 am
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.

Posted: Wed Aug 24, 2005 10:05 am
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.

Posted: Wed Aug 24, 2005 10:17 am
by pnchowdary
Hi NaveenD,

As Arndw already pointed out. /Q switch in Del command, suppresses the confirmation message when deleting mutliple files using wildcards.

Posted: Wed Aug 24, 2005 10:41 am
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

Posted: Wed Aug 24, 2005 10:43 am
by Sainath.Srinivasan
The req is in Win.

Posted: Wed Aug 24, 2005 4:40 pm
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.