Description
Given a data file, in which
- every line consists of several fields, assume 7 in this case.
- the delimiter used is '|'.
- if a line contains less than 6 delimiters,
we assume that there exists null field(s) without delimiter(s)
at the end of the line.
The job is adding delimiters to make these null fields clear.
|
| Raw Input
| G725||144235|N|N|Y|16221
A742|Y|392176|N|N
B329|N|653014|Y|Y|N
Z320|Y|563912|N
Q109
|
|
| Desired Output
| G725||144235|N|N|Y|16221
A742|Y|392176|N|N||
B329|N|653014|Y|Y|N|
Z320|Y|563912|N|||
Q109||||||
|
|
Script and Comments
Script1 [ 1] s/$/||||||/
[ 2] s/^(([^|]*\|){6}[^|]*).*/\1/
| |
Script2 [ 1] s/$/||||||/
[ 2] s/|/\n/7
[ 3] P
[ 4] d
| |