Page 1 of 1

rearrange columns in csv file

Posted: Thu Sep 09, 2010 8:01 pm
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:

Posted: Thu Sep 09, 2010 10:13 pm
by keshav0307
does the files contains column names?

Posted: Thu Sep 09, 2010 11:30 pm
by BMSK
First read the file as its comes through sequential stage, Then put copy stage and arrange colum as you needed... :wink:


BMSK

Posted: Fri Sep 10, 2010 12:04 am
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.

Posted: Fri Sep 10, 2010 8:43 am
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.

Posted: Fri Sep 10, 2010 8:44 am
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.

Posted: Fri Sep 10, 2010 10:16 pm
by madhav62
any one has any idea

Posted: Fri Sep 10, 2010 10:19 pm
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

Posted: Sat Sep 11, 2010 3:12 am
by ray.wurlod
Probably not. U (one of our posters) has not been involved in this thread.