cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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?

Regards,

Gannu.

Accepted Solutions (1)

Accepted Solutions (1)

former_member106536
Active Participant
0 Kudos

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.

Former Member
0 Kudos

Thanks for the information Joshua Blythe. However i am fully not understood that using row generator we can achieve the static header name value gets changed with global variable.

Also provide me some sample in case you.

I have almost 15 columns(headers) name in which the names should be updated with global variable.

so let me know is there any other simplest way to this. I read something about STYLE (BOF/EOF Marker). Any info. on this.

Regards,

Gannu

former_member106536
Active Participant
0 Kudos

You have a query following the row_gen transform, with columns matching your detail schema.  In the mappings for each column, you'll have your global variable.

If you choose to use only one row gen transform, you decode on the row_id field, for which variable for which column you want.  (this is in your query mappings)   Doesnt get much easier.

Former Member
0 Kudos

Ok Joshua. I will try on this. Thanks for the information.

Former Member
0 Kudos

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.

Regards,

Gannu

Answers (0)