remove blank lines from end of file
Moderators: chulett, rschirm, roy
remove blank lines from end of file
Hi All,
We get flat files which have blank lines at the end of the file. This creates the "Mismatch in number of columns" error.
How to get rid of the lines? Before-job subroutine calling a shell script?
Can i get some ideas as to how to write the script?
Thanks in advance
J
We get flat files which have blank lines at the end of the file. This creates the "Mismatch in number of columns" error.
How to get rid of the lines? Before-job subroutine calling a shell script?
Can i get some ideas as to how to write the script?
Thanks in advance
J
Invoke Tranform Stage And map All The Columns And Define Below Constraint To Eliminate Last New Line Or Blank Line.
But Make Sure You Do this On Key Column or Key Columns Which Doesnt Have Spaces.
DSLink.ColumnName > ' ' (Here Take One Key Column)
Or
(Col1:Col2:Col3:Col4) > ' ' (Here U Can Take Multiple Key Columns)
Good Luck
But Make Sure You Do this On Key Column or Key Columns Which Doesnt Have Spaces.
DSLink.ColumnName > ' ' (Here Take One Key Column)
Or
(Col1:Col2:Col3:Col4) > ' ' (Here U Can Take Multiple Key Columns)
Good Luck
The sed command is very fast and can delete blank lines. I can't remember exactly the syntax but it something like
This says delete all lines which have the begining of a line ^ next to the end of a line $ and nothing in between.
Code: Select all
sed '1,%g/^$/d'
Mamu Kim
Craig is correct. It is a simple UNIX command. It is very fast. It has very ugly syntax. You suggested that you had many blank lines and this will solve that problem. I think this has been covered so I would do a search on here and maybe Google.
You can ignore these errors in the sequential stage. You would also need a constraint in the output link. A couple of options available to you.
You can ignore these errors in the sequential stage. You would also need a constraint in the output link. A couple of options available to you.
Mamu Kim
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Expanding slightly on what Kim said.
You can set the "missing columns" rules in the Sequential File stage (Columns grid - scroll right to find them) to have DataStage ignore the fact that there are missing columns, pad with null, etc.
Then you constrain the output so that these rows are not output, using an output constraint expression in the Transformer stage.
You can set the "missing columns" rules in the Sequential File stage (Columns grid - scroll right to find them) to have DataStage ignore the fact that there are missing columns, pad with null, etc.
Then you constrain the output so that these rows are not output, using an output constraint expression in the Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.