add a new row in the beginning of a file

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 !
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?
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.
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).
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.
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.