Problem Statement
In Talend, while generating output file if we need to add a column as number or column name with space or to include any special characters as column name in Talend it won’t allow directly by adding the below-mentioned column names in schema, will get the below mentioned error.
As number as column name:
As space in column name:
As special characters in column name:
Solution:
The above use case was implemented by simple Talend job and with the below steps.
Step 1: To use tFixedFlowInput component by providing the actual column names (number/special character/space) as highlighted below,
Step 2: To map the fields to the target file to populate the headers in the first line of the output.
Step 3: To load the actual source data which we need to load it in output target file will be done in step 3. The source data can be a Input File or any other stream of data. Here input file is used as a source for example.
Step 4: In order to avoid the header from actual file used and to pick the headers from the previous flow we need to use sequence and given condition to pick the records which has sequence more than the value 1 as below in tMap.
Step 5: To load the source data after tMap to the same target file using append operation on addition to the header load from the previous flow.
with the same concept we can replace the output component instead of tFileOutputDelimited to tFileOutputExcel for generating excel.
Result:
The output file is generated after the execution of the job and the given columns are loaded successfully as below in header of the target file.