One Star

Dynamic column name in CSV

Hello,
I have a csv file with a hundred column. The first row of each column is the name of this column.
I need to split this file to different output (other files, DB...). Those output always use the same column (based on the name).
My problem is that the csv file will change by the order of the column. So i never know which column i need to extract. So i need to map to map my csv column order to a predefiend column order. How can i do that ?
ex:
the CSV file can look that way :
name1; name2; name3
value11;value21;value31
value12;value22;value32
value13;value23;value33
or that way:
name1; name3;name2
value11;value31;value21
value12;value32;value22
value13;value33;value23

i was thinking using context variable where columnName= a variable defined by this name. I'm not sure if it's the best solution.
I'm using Talend 3.1
thanks for any help.
4 REPLIES
Seven Stars

Re: Dynamic column name in CSV

You can download a sample job of how to do this from the exchange, it also includes a routine that facilitates this. The link for the sample job is http://www.talendforge.org/exchange/tos/extension_view.php?eid=177
Hope that helps.
One Star

Re: Dynamic column name in CSV

i downloaded the job but i don't know ho to run it. Talend does not recognize it as a project, and when i try to mix this file with an empty project, i got nothing more in the editor.
Community Manager

Re: Dynamic column name in CSV

Hello
to rbaldwin:
I download your job and import it into my TOS. but I don't see the input file: sample.xls
Can you check and upload it aslo again?
to lkryss:
To import a job, right click on 'Job Designs' on Repository and select 'import item' option.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: Dynamic column name in CSV

Shong, the file is in the documentation section of the repository with that job. So, if you imported everything, you'll have the excel file. You'll have to setup the context to point to where you put the file, though.