I have a flat file (see attached)
I need to remove the leading zeros at the start of the line only. ie 00008 to 8
I can remove the leading zeros via a tcl proc but it wont read the message in.
proc removeLeadingZerosPerLine {DATA args} {
echo “RUNNING PROC VERSION: PRE-WRITE SIGNATURE”
echo “removeLeadingZerosPerLine: START”
echo “Original DATA:\n$DATA”
set message $DATA
set outLines {}
set lineNum 0
foreach line [split $message “\n”] {
incr lineNum
set line [string trimright $line “\r”]
echo “Line $lineNum BEFORE: ‘$line'”
if {[string match “*UKBTSSTART*” $line] ||
[string match “*UKBTSSTOP*” $line]} {
set line “[string range $line 4 end]”
} elseif {[regexp {^0000[0-9]} $line]} {
set line “[string index $line 4][string range $line 5 end]”
}
lappend outLines $line
}
set newMessage [join $outLines “\r\n”]
echo “FINAL transformed DATA:\n$newMessage”
echo “removeLeadingZerosPerLine: END”
return $newMessage
}
I can remove via a translation – using xlateStrTrimLeft 0000 but it will only remove the zeros from the first line and wont read in the other lines (delimited by <CR><LF> – which need to remain.)
(I have create the translation using FRL and VRL)
Any help appreciated