Splitting the file Logically

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
vij
Participant
Posts: 131
Joined: Fri Nov 17, 2006 12:43 am

Splitting the file Logically

Post by vij »

Hi all,

I have a requirement which goes like this - A .txt file should be splitted (logically) based on the memory / size of the data and a hard coded value should be appended for each and every split and written into a output file.

To explain it more clearly- The input file which is more than 256KB for an example say 2560KB, should be read and when it crosses 256KB, a new line should be appended and then the next 256KB should be written to the same file followed by the same appended line, when it crosses 256KB, and so on..

Please let me know how to do this on DS.

Thanks!
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You cannot split based on Size using DS. But you can make use of the OS command in DS. You can use "split" command with the size given as parameter in execute command activity, to split the files into several sub files. Later using FilePatter option available in sequential file, you can merge all the file or using Filter option, you can merge with new line concatinated to each file.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can also use awk to append lines. Its better to do number of lines then number of bytes.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

If you know the whole file size and if you know what size you need to split into, you can as well use "Sample" stage with percentage values given.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply