adding column names to reject 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

ssunda6
Participant
Posts: 91
Joined: Tue Sep 19, 2006 9:32 pm

adding column names to reject file

Post by ssunda6 »

Hi,

I have a requirement of having column names in addition to data in a file.
Any inputs as to how to do this will be of great help.

regards
ssunda
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hi,

You can use column generator to create extra columns in a file with the data.

FILE with (50columns) ----- Column Generator--------- FILE with (60 Columns).

Just try out this........
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
jhmckeever
Premium Member
Premium Member
Posts: 301
Joined: Thu Jul 14, 2005 10:27 am
Location: Melbourne, Australia
Contact:

Post by jhmckeever »

ssunda,

I read your original post as requiring column headings in your output file. One way to do this is to use a before-job execSH to echo the column headings to your file (creating the file in the process), then set your sequential file stage to 'append' rows to the file. To avoid name mismatch your filename should be a job parameter which is referenced in your sequential file and ExecSH command.

HTH,
J.
<b>John McKeever</b>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

Are you trying to read from a file which has column names in the header or write in the file and want to have column names in output file in addition the data in the file :?:

Edited to add-
If you reading such file, command filter with tail command can be used to drop the column names while processing.
While writing you can set the property - first line is column names as true.
Regards,
S. Kirtikumar.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Where's the reject link beginning? Reject links from Sequential File stage, for example, contain only one column, containing the source row as a Raw string. This can certainly be written to a file. But the question of adding additional columns may become tricky - you would need to guarantee that the delimiter characters match those expected from source. And that the record schema managed the raw string and the other columns.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Where's the reject link beginning? Reject links from Sequential File stage, for example, contain only one column, containing the source row as a Raw string. This can certainly be written to a file. But the question of adding additional columns may become tricky - you would need to guarantee that the delimiter characters match those expected from source. And that the record schema managed the raw string and the other columns.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
tagnihotri
Participant
Posts: 83
Joined: Sat Oct 28, 2006 6:25 am

Re: adding column names to reject file

Post by tagnihotri »

If I am getting this right! you want to generate the collumn names in the output seq file along with the rejected data and because the meta data format of the reject link is raw you can not set the property 'First Line asd Collumn Name'. I suggest if this is the case better use one more stage and set the property there. I think as data flowing from reject link can be used without modification therefore this shoud work this way!
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

Hi Ssunda,
If i am getting your ques. right, then ...you are writing from File to File and at transformer you are taking one Reject Sequential file.what i can suggest you is...Hardcord the column name and then concatenate it with your data.
If your Column is TRY the use "TRY":inputlink.col.name.
please correct me if i am worng.

Thanks.
ambasta
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

We've now got six replies to the original post (seven if you count Ray's double) all guessing what ssunda's actual problem is. Rather than having any more well intentioned people pile on with their entry into the contest, here's a thought...

:idea: Why not wait for the OP to come back and clear things up? It blows my mind how long some of these threads get with only the original post for guidance. That's usually because the original question is just as vague as this one - where the appropriate first response should be a plea for clarification IMHO.

Or just continue to "tawk amongst yourselves". :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Surely that's why the RMM stage exists? :lol:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I concur... but please don't call me Shirley. :P
-craig

"You can never have too many knives" -- Logan Nine Fingers
ssunda6
Participant
Posts: 91
Joined: Tue Sep 19, 2006 9:32 pm

Post by ssunda6 »

Hi all,

sorry for replying so late. I dont have reject link from sequential file. Reject links are from stages like transformer, lookup.

For one of my files I have 150 columns, so hardcoding the column names is difficult.

Iam not reading from files which have column names, instead I am trying to write column names to a reject file along with data.

Thanx for the replies.

regards
ssunda
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

ssunda6 wrote:Hi all,

sorry for replying so late. I dont have reject link from sequential file. Reject links are from stages like transformer, lookup.

For one of my files I have 150 columns, so hardcoding the column names is difficult.

Iam not reading from files which have column names, instead I am trying to write column names to a reject file along with data.

Thanx for the replies.

regards
ssunda
Hi Ssunda,
what i can suggest you is...while loading the meta data for filw,you can set the property as [first line is column names] as true.I f you will do that then u can very well see ur column names.and i don't think there is any escape route[Guys! correct me if i m wrong],you will have to Hardcode the col. name then concatenate with values.

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

Adding column names manually

Post by ray.wurlod »

It's not difficult. It's tedious - not the same thing. It's something you only need to do once. Do it. Save into Repository so it's re-usable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ssunda6
Participant
Posts: 91
Joined: Tue Sep 19, 2006 9:32 pm

Post by ssunda6 »

Hi all,

I set the property "first name column names= true", and the column names along with data is being written to the reject file. So, I dont think we need to hard code the column names again. Correct me if im wrong.

Thnx all for the replies.

regards,
ssunda
Post Reply