Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to read only First and Last lines of the File

I want to read only First and Last lines from the file. is it possible? do we have any component
Labels (2)
6 Replies
Anonymous
Not applicable
Author

Hi
It is easy to read only first lines from a file, just need to set the header.
To read the last lines, you need use a tFileRowCount to get the number of lines first and then use a tSampleRow to read a range of lines, for more details, please see my screenshots.
Best regards
Shong
Anonymous
Not applicable
Author

Thanks Shong.
Anonymous
Not applicable
Author

it seems like tFileRowCount component is having a bug in it.
if I select the option "IgnoreEmpty rows" with row separator as "\n" , it still counts the rows but with
System.getProperty("line.separator").toString()

in the row separator is ignoring the empty rows.
this is not the case in tFilePositional or any other file reading components.
Anonymous
Not applicable
Author

it seems like tFileRowCount component is having a bug in it.
if I select the option "IgnoreEmpty rows" with row separator as "\n" , it still counts the rows but with
System.getProperty("line.separator").toString()

in the row separator is ignoring the empty rows.
this is not the case in tFilePositional or any other file reading components.

Hi
Which version are you using? I tested it on v4.1.2 and it works.
Best regards
Shong
Anonymous
Not applicable
Author

I have this problem on TDQ 4.0.1 R41260
sreemanthri
Contributor
Contributor

i'm not finding the screenshot for the post can you please share it