Flat File

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
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Flat File

Post by kittu.raja »

Hi,

I got a file which has only one column and one row. It has 10 lines of data. If I want to add one line at the top and one line at the bottom to the data file. How can I achieve this.
For example

Input:
clo1
I am a very good boy

Output should be like this

Output:
col1
Suresh
I am a very good boy
Bye

Thanks,
Rajesh
Rajesh Kumar
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

What do you mean by
  • one line at the top and one line at the bottom to the data file
header and trailer records?.
Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives.
By William A.Foster
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What is your source for these other records? There's probably some fancy PX way to do that, but you could also write those out to two other files and then cat them together in the proper order after job. Worst case. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
filename.txt
Participant
Posts: 27
Joined: Thu Mar 20, 2008 11:55 am

Post by filename.txt »

I think its a unix question..

file1 contains "I am a very good boy"

then.. a sequence of commands or script like below will give you desired output.

echo "suresh" > file2
cat file1 >>file2
echo "bye" >>file2
Thanks.

"Creativity is the ability to use your available resources to their fullest."
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or simply:

Code: Select all

cat file1 file2 file3 > file4
So as to not destroy the original "file2" file and allow it to rerun without much in the way of shenanigans.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

For a parallel job solution, you can use a funnel stage with a funnel type of Sequence to do concatenation.

Mike
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I got a file which has only one column and one row. It has 10 lines of data.
These statements are mutually inconsistent.

If you are adding hard-coded text to the beginning and end, you could set up a Filter command in your Sequential File stage. Something like:

Code: Select all

echo Suresh && cat #MyDir#/#MyFile# && echo Bye
The Sequential File stage will read the output from this command.
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