$a = Invoke-WebRequest ftp://ftp.cmegroup.com/SBEFix/Production/TradingSessionList.dat $b = [System.Text.Encoding]::UTF8.GetString($a.Content) $lines = $b.Split("`n") $parsed_lines = @() foreach($line in $lines) { $fields = $line.split([char]1) $fix_pairs = @() foreach($field in $fields) { $field -match "(?\d+)?=(?.*)" | % { $fix_pairs += new-object PSObject -prop @{ tag=$matches['tag']; value=$matches['value'] } } } $product_complex = $fix_pairs | ? { $_.tag -eq 1227 } | select -expand value $market_segment_id = $fix_pairs | ? { $_.tag -eq 1300 } | select -expand value $security_group = $fix_pairs | ? { $_.tag -eq 1151 } | select -expand value $parsed_lines += new-object PSObject -prop @{ market_segment_id = $market_segment_id; product_complex = $product_complex security_group = $security_group } } $parsed_lines | Export-Csv -NoTypeInformation -Encoding ASCII trading_session_list.csv