add a new row in the beginning of a file

Highlighted
One Star

add a new row in the beginning of a file

Hi,
I want to add a row ( header ) to my file. it has to be in the beginning, but i'm finding it hard to do. I have more than 200 columns and some columns are integer, Date or string type. Can anyone show me how to do it ? Thanks !
Highlighted
Five Stars

Re: add a new row in the beginning of a file

tFileOutputDelimited has the option to 'Include Header'. There are some edge cases where this does not work well. In these instances, you can write your file twice - once for the header and once for your data, remembering to 'Append' when you write your data.
For example: -
tFixedFlowInput->tFileOutputDelimited (no header, no append) to write your header
tMySQLInput->tFileOutputDelimited(no header, append) to write your data
I would recommend 'Include Header'. If this is not working for you, what is the issue?
Highlighted
One Star

Re: add a new row in the beginning of a file

Thank you Tal for your quick response.
Actually, i've done some jobs on my file. During this process, i removed the header from the file because of some errors i had. Now that my jobs are done. I want to add the header again. My files are stored in cloudera. i tried creating a file were i have only my header and add the data stored in the other files into it. But it doesn't work.
Highlighted
One Star

Re: add a new row in the beginning of a file

Any updates on this topic?
I have a similar problem. I want to split big files to smaller ones and add a row on the very beginning of the smaller file(s).
Highlighted
Five Stars

Re: add a new row in the beginning of a file

tFileOutputDelimited has the option to split.
Take a look at Advanced settings->Split output in several files
Talend will manage headers for you.
Highlighted
One Star

Re: add a new row in the beginning of a file

Thanks or reply.
I already use this option. I want to add a first row with a different schema after splitting the file.

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 2

Part 2 of a series on Context Variables

Blog

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