One Star

Read Specific Record from txt file

Hi All,
My source is a Delimited file. I have around 1000 records. First record contains only date to identify that file is today's file. How can I read the first line alone for validation? And also assist on how to read a specific record from a file( for example 10th record,100 th record etc,.) .

Kindly assist.
Thanks,
Saty.
4 REPLIES
Community Manager

Re: Read Specific Record from txt file

Hi
To read the first N line, you can set the Limit field on tFileInputDelimited to let the component only read the first N line, for example, set Limit as 1 to read the first line. To read a range of lines, for example, from 10th line to 20th line, you can use tSampleRow component.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Read Specific Record from txt file

To read the first N line, you can set the Limit field on tFileInputDelimited to let the component only read the first N line, for example, set Limit as 1 to read the first line. To read a range of lines, for example, from 10th line to 20th line, you can use tSampleRow component.

Thanks Shong. I have one doubt. I have N no. of records in a text file. How can I select last record from the this file?
Kindly assist.
One Star

Re: Read Specific Record from txt file

I have N no. of records in a text file. How can I select last record from the this file?

Hi All,
Kindly someone assist on this.
Seven Stars

Re: Read Specific Record from txt file

The best way is probably to use tFileRowCount to get the number of records and then pass that as a variable to tFileInputDelimited's Header field (-1).