Page 1 of 1

Flat File

Posted: Thu Nov 20, 2008 3:17 pm
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

Posted: Thu Nov 20, 2008 3:29 pm
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?.

Posted: Thu Nov 20, 2008 3:30 pm
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:

Posted: Thu Nov 20, 2008 3:35 pm
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

Posted: Thu Nov 20, 2008 3:40 pm
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.

Posted: Thu Nov 20, 2008 3:42 pm
by Mike
For a parallel job solution, you can use a funnel stage with a funnel type of Sequence to do concatenation.

Mike

Posted: Thu Nov 20, 2008 4:31 pm
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.