One Star

Column names with spaces

I need to create an excel output file that uses column headers with spaces, it doesnt look like this is possible is there any work around? I need to you spaces I cannot use _
thanks
10 REPLIES
Community Manager

Re: Column names with spaces

Hello
Column name can't contain spaces. You can use underline '_'.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Column names with spaces

A little more information, I
One Star

Re: Column names with spaces

why? Excel give the possibility to use space in column name
Community Manager

Re: Column names with spaces

why? Excel give the possibility to use space in column name

Talend Studio is a Java code generator, a Talend job will be translated to a Java Class, a column on the schema will be a variable in the class, a variable with space or special character is not allowed in Java.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Column names with spaces

any workaround??
Community Manager

Re: Column names with spaces

any workaround??

Column name can't contain spaces. You can use underline '_' or Talend will replace automatically space with "_" when retrieve schema.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seventeen Stars

Re: Column names with spaces

You cannot specify column names in Excel. You can write anything you want in the first line and decide to call it header line. That's why it looks like Excel allow spaces in column names but actually there are no column names other than the build in name like "A" or "AB"
One Star

Re: Column names with spaces

hi,
you can generate the 1st line with a tFixedFlowInput and complete your excel file without column titles.

Re: Column names with spaces

We have a hard requirement to create output columns with spaces. I wrote this to a co-worker - any better alternatives? We try to stay Talend only, no external utilities like sed.
It will be ugly: You'll have to do 3 things:
1) write out the header to a temp file with tokens like +++SPACE+++ where there should be spaces (make the column name First+SPACE+Name).
2) rewrite the header out to the real output location, using java, String.replace " " for the token - you can write it out as a one column schema and tFileOutputDelimited for example, using some delimeter that will never come up
3) append to the header file with the real data
So that is a terrible solution but I think what we'll end up with.
Community Manager

Re: Column names with spaces

Hi
As Cedric LECLERC said, use a tFixedFlowInput to write the header data to the file first, and then append the record to the same file in next subjob.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business