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 :-)

View solution in original post


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 :-)

View solution in original post

Four Stars

Re: Varying Header Size

Thank you, this worked very well!

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

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

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog