Varying Header Size

Highlighted
Four Stars

Varying Header Size

I have datasheet text documents that I am inputting with tFileInputDelimited. They are formatted the same way, but their headers vary in number of lines. However, the end of the header is always signified by the same string, "Results". Is is possible to signify the end of a header with a string, instead of specifying the number of lines of the header?

 

PS I am very new to Talend and am using v 4.1.1


Accepted Solutions
Employee

Re: Varying Header Size

Hi,

 

   One method is to read the file first time with 0 header and parse the data using Java functions to check whether the string "Results" is present. You can note the line number (you can create a numeric sequence in tMap to add additional line number column) of the row where this string comes and note it to a context variable.

 

   Then you will have to read the file second time and this time, provide the header number from context variable instead of default value of 0. Then you can read the data from that row onwards. The flip side is that you are reading the file twice.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


All Replies
Employee

Re: Varying Header Size

Hi,

 

   One method is to read the file first time with 0 header and parse the data using Java functions to check whether the string "Results" is present. You can note the line number (you can create a numeric sequence in tMap to add additional line number column) of the row where this string comes and note it to a context variable.

 

   Then you will have to read the file second time and this time, provide the header number from context variable instead of default value of 0. Then you can read the data from that row onwards. The flip side is that you are reading the file twice.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Four Stars

Re: Varying Header Size

Thank you, this worked very well!

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download