the names of the colunms are numbers

Highlighted
Five Stars

the names of the colunms are numbers

Hi everyone,

 

I have a problem with the names of the columns. Indeed, I created a file delimited in the metadata section to be able to import via this schema data from a delimited files. 

The problem is that my header contain number as names of columns, example of header: name_col_one;name_col_two;2010;2011.

Therefore, at the end of the creation of the metadata, when I choose the option 'Set heading row as column names', I have a '_', for example name_col_one;name_col_two;_010;'_011.

 

I really need to have a correct name of column because the next step is to unpivot my table and I don't want to have this kind of record name_col_one;name_col_two;_010;'value1_from_2010

name_col_one;name_col_two;_010;'value2_from_2010

 

but I want:

name_col_one;name_col_two;2010;'value1_from_2010

name_col_one;name_col_two;2010;'value2_from_2010

 

Thank you in advance


Accepted Solutions
Highlighted
Sixteen Stars
Sixteen Stars

Re: the names of the colunms are numbers

To have a new header, just define it in a tMap and map columns from old schema manually.

TRF

View solution in original post


All Replies
Highlighted
Five Stars

Re: the names of the colunms are numbers

I forgot to say that I have more than one hundred columns, therefore, I cannot use a replace function in the tmap to change the '_' by '2'
Highlighted
Sixteen Stars
Sixteen Stars

Re: the names of the colunms are numbers

Having column names starting by number is forbiden because of Java (see namming rules)

TRF
Highlighted
Five Stars

Re: the names of the colunms are numbers

Hi,

 

Thank you for your reply.

So, I cannot do anything?

 

I thought about something but I don't know if I can do it (I'm a beginner in Talend)

 

 

It is possible to add "manually" a header to use a Treplace component?

 

For example, after my unpivot, I have these records:

value1_from_column_one;value1_from_column_two;_010;'value1_from_2010

value2_from_column_one;value2_from_column_two;_010;'value2_from_2010

 

I add the "new" header to have this structure:

new_column_one; new_column_two;year;value

value1_from_column_one;value1_from_column_two;_010;'value1_from_2010

value2_from_column_one;value2_from_column_two;_010;'value2_from_2010

 

And after that, I use the Treplace component on the field "year" to replace all '_' by '2'.

 

The question is: How to add the new header?

 

Thank you very much in advance

 

 

Highlighted
Sixteen Stars
Sixteen Stars

Re: the names of the colunms are numbers

To have a new header, just define it in a tMap and map columns from old schema manually.

TRF

View solution in original post

Highlighted
Ten Stars

Re: the names of the colunms are numbers

I have several use cases where the output header format is not allowed by Java constraints.  You can write out the header first, then append your results to the same file.

Highlighted
Five Stars

Re: the names of the colunms are numbers

Hi again,

 

Thank you, it's works with the Tmap. I used the function StringHandling.CHANGE in my "new" header, which has been created in the Tmap as suggested.

 

Thank you again

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog