[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.
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.
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"))
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
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.
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 ?
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.