Skip to Content
author's profile photo Former Member
Former Member

How to change Header Name with global variable value in the output file.

Hi All,

Here is the requriment:

I am developing a job and the output is going to be a csv file. I would like to change few columns header name with global variable value.

Means: how to change a static header name to global varilable name.

For Ex:

Header 1 to 2013-12

Header 2 to 2014-01

Header 3 to 2014-02

The global variable value will keep on change at run time and that value should assigned to Header1, Header2, Header3 correspondingly.

I wanted to handle this in DS rather handling it Unix after the file generation.

I tried Column Attributes by setting Global Variable in the 'Value' field and not getting the desired result.

Pls. let me know is there a possibility to do within DS?



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Nov 14, 2013 at 02:15 PM

    You could use a row generator transform to create the headers, adding a sequence number field. (values 1,2,3) Then add a sequence column to your detail records (4). Merge them together using a common schema, and following the merge you sort on the appended sequence. Strip the sequence column and you're done.

    If you need a trailer, add another row to your row gen. You could use a decode to set the column values to your variables, or use one row gen per header.

    Doing it this way saves from having to write the headers in a separate dataflow, merging it with the detail records. Ive always thought this was pretty sloppy unless your headers have different record lengths/layouts. Of course you may not want to use this method if you've got a large detail record set.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi All,

      FYI: Changing header field name dynamically can be done by using 2 DF and i am able to acheive it.

      create 2 dataflows.
      1. In first dataflow insert header. ( Pass global variable in query transform ).

      2. Suppress the row header

      3. In Second dataflow append other records. ( Make sure that Do Not Delete flag in unchecked in target file format in 2nd dataflow. Also write row header make it no.)

      This trick in neater than appending header to file via Unix Script.



Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.