Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] how to remove fisrt and last line from a text field ?

Hello,
I'am trying to remove the first line and the last line from a text field.
This can be done with tFileInputDelimited by setting header and footer parameter but this doesn't sound as the good solution.

could you help me ?
k.regards
Nicolas
Labels (2)
10 Replies
Anonymous
Not applicable
Author

Hello
Using the tFileInputFullRow with setting header and footer.
Best regards
Shong
Anonymous
Not applicable
Author

Thanks ! I'll try it now.
k.regards
tvsr984
Contributor
Contributor

I have a input text file with some text inside it. I want to delete the first two lines and get the same output. I want to do it for a set of files automatically rather manually.
See my sample i/o attached.
 in the input two lines are blank before the text.
I want the Output after removing the first two blank lines.
Note: It's a text file with loat of paragraphs, can't denote them in rows/columns
The input, output(desired) files are attached
Kindly advice.
Anonymous
Not applicable
Author

Hi tvsr984
If all these files are in the same folder, you can use tFileList to iterate all the files, use tFileInputFullRow to read each file line by line and set the header as 2 to split the first two rows, write the lines to a new file. For example:
tFileList--iterate--tFileinputFullRow--main--tFileOutputDelimited.  
on tFileINputFullRow: set the file path as:
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
on tFileOutputDelimited: set the file path as:
"yourFolder/"+((String)globalMap.get("tFileList_1_CURRENT_FILE"))
tvsr984
Contributor
Contributor

Thanks Hong for the timely rely.
I did the exact same what you described. But the issue is the output file has extra line spaces and the tab space comes in before every line the line seperator is \n and filed seperator is " ".
Any idea what might be the issue?
Thanks
Anonymous
Not applicable
Author

The line read from the source file, I don't understand why the output file has extra line spaces. Can you show me an example file?
tvsr984
Contributor
Contributor

Thanks hong. I found the issue. I just put in the line seperator as "\r\n" at the ouput end instead of "\n" alone. That does the magic!!. Thanks a lot for your support in the needy time.
Anonymous
Not applicable
Author

Hi All,
I have 2 fixed length text files with below mentioned contents -
Main Header
Sub-Header-1
Row-1
""
Row-10
Sub-Footer-1
Sub-Header-2
Row-1
"
Row-10
Sub-Footer-2
Main Footer
Now i need a same Fixed length text file with following output -
Main Header
Sub-Header-1
Row-1
""
Row-10
Sub-Footer-1
Sub-Header-2
Row-1
"
Row-10
Sub-Footer-2
Sub-Header-3
Row-1
""
Row-10
Sub-Footer-3
Sub-Header-4
Row-1
"
Row-10
Sub-Footer-4
Main Footer
What approach I have to follow here ?
cterenzi
Specialist
Specialist

If all you're doing is combining the files without needing to transform anything, you can read in file1 stripping the main footer and write to a new output file, then read in file2 stripping the main header and append to the same output file.