rearrange columns in csv 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
madhav62
Premium Member
Premium Member
Posts: 15
Joined: Sun Aug 15, 2010 9:26 pm

rearrange columns in csv file

Post by madhav62 »

HI
I have a question
i have few csv file in my server and the columns changes very day and file to file.
like for example for invoice1.csv columns are:
Invoice number, customer_id, Valid_from, Valid_to, extraction_time,user_code,emp_id
and second file invoice2.csv columns are:
extraction_time,user_code,emp_id,Invoice number,customer_id, Valid_from, Valid_to.
And i need the file to be some order like:
Invoice number, customer_id,user_code,Valid_from, Valid_to,extraction_time,
emp_id. for datastage or lets say the order in which i want the columns to be.
Can Any one suggest me an idea :idea:
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

does the files contains column names?
BMSK
Participant
Posts: 41
Joined: Wed Feb 06, 2008 7:00 am
Location: Bangalore

Post by BMSK »

First read the file as its comes through sequential stage, Then put copy stage and arrange colum as you needed... :wink:


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

Post by ray.wurlod »

If it's always the same six fields the first thing I'd be doing is getting the provider of the file to be consistent.

If you can't do that, you need to determine which column is which. If there are column headings this ought to be easy. In a Transformer stage you could use RCP to direct the correct columns to the output link.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
madhav62
Premium Member
Premium Member
Posts: 15
Joined: Sun Aug 15, 2010 9:26 pm

Post by madhav62 »

ray.wurlod wrote:If it's always the same six fields the first thing I'd be doing is getting the provider of the file to be consistent.

If you can't do that, you need to determine which column is which. If there are column headings this ought to be easy. In a Transformer stage you could use RCP to direct the correct columns to the output link.
Yes It is same six fields and column names are in first line.
madhav62
Premium Member
Premium Member
Posts: 15
Joined: Sun Aug 15, 2010 9:26 pm

Post by madhav62 »

ray.wurlod wrote:If it's always the same six fields the first thing I'd be doing is getting the provider of the file to be consistent.

If you can't do that, you need to determine which column is which. If there are column headings this ought to be easy. In a Transformer stage you could use RCP to direct the correct columns to the output link.
Yes It is same six fields and column names are in first line.
madhav62
Premium Member
Premium Member
Posts: 15
Joined: Sun Aug 15, 2010 9:26 pm

Post by madhav62 »

any one has any idea
madhav62
Premium Member
Premium Member
Posts: 15
Joined: Sun Aug 15, 2010 9:26 pm

Post by madhav62 »

BMSK wrote:First read the file as its comes through sequential stage, Then put copy stage and arrange colum as you needed... :wink:


BMSK
can u elaborate the approach
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Probably not. U (one of our posters) has not been involved in this thread.
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