I need to parse a structured file (FIX protocol 4.4) in powershell. The structure is like this
20220606-21:10:21.930 : 8=FIX.4.49=209 35=W34=35 49=FIXDIRECT.FT 52=20220606-21:10:21.925 56=MM_EUR_FIX_QS 55=US30 262=96 268=2 269=0 270=32921.6 271=2000000 299=16ynjsz-16ynjsz5qCaA 269=1 270=32931.4 271=2000000 299=16ynjsz-16ynjsz5qCaA 10=048
I need to pick only specific values following tags. I need the first value (timestamp) until the colon which does not have a tag number but then need to pick values following specific tag numbers. For example tag values 55, 270 and 271 (multiple 270 and 271 values exist here)
I am able to parse utilizing a simple ordered method of " "
and "="
as delimiters
$contents = Get-Content FIX.log
foreach($line in $contents) {
$s = $line.split("= ")
write-host $s[0] $s[17] $s[25] $s[27] $s[33] $s[35]
}
however I prefer to be able to pinpoint the value using the tag numbers as there are some lines in the file that do not conform to the same content.
Result should be something like this
20220606-21:10:21.930 US30 32921.6 2000000 32931.4 2000000