Page 1 of 1

Splitting to multiple files at runtime

Posted: Wed Aug 27, 2008 12:46 am
by Django
I have got a source text file as follows

Code: Select all

-------------------------------------------
TargetFileName DataCol1 DataCol2
--------------------------------------------
ABC.txt                1             2
ABC.txt                5             6
ABC.txt                11            12
ABC.txt                41            24
DAMMY.txt           12             23
DAMMY.txt           34             45
DAMMY.txt           24             99
... and so on...

The number of TargetFileName is variable

Now I want to create output files as per the TargetFileName column. Ie. One file named ABC.txt and one file named DAMMY.txt and so on each on which will have only the columns DataCol1 and DataCol2.
Note - The number of TargetFileName is variable... thats what has made me come to this forum...

Posted: Wed Aug 27, 2008 1:19 am
by ray.wurlod
Ok, then. Go for it.

Help!!

Posted: Wed Aug 27, 2008 1:47 am
by Django
I need help here, please.

While reading a sequential file stage it allows to read from multiple files using pattern. What about while writing ?

Posted: Wed Aug 27, 2008 2:23 am
by ray.wurlod
Create a server job that reads your file and invokes UtilityRunJob() to run a generic job that takes the file name (and anything else needed) as a job parameter.

You could do the same with a job sequence (instead of a server job), if you read the file then convert the line terminators into a delimiter that the StartLoop activity can use. Within the loop is your generic job.

Unix Awk does it all

Posted: Thu Aug 28, 2008 12:58 am
by Django
After Job Sub-Routine : ExecSH

cd #SWorksOutputFilePath# ; awk -F, '{print > $2}' Sales.Imp ; awk -F, '{print > $2}' HistData.Imp

did it all :lol:

Col No. 2 in the file carries the filename.

Thanks to my collegue Gary ...

Explored options

Posted: Thu Aug 28, 2008 12:59 am
by Django
Thanks to Ray's post. It made me explore various options...