# ZGM_VisO_biedi2csv MS Powershell script
 
$d = gc mission.biedi 																								# Read the incoming 3Deditor file
$rows=@()   
for ($i=0; $i -le $d.count -2; ++$i) {                                          
    if( $d[$i] -match "POSITION" ) { 
        $pos = $d[$i].Replace('POSITION="[', '').Replace(',',';').Replace(']";','').Replace(' ', '').trim()
        if (($pos -split ';').count -eq 2) {$pos += ";0"}
        $typ = $d[$i+1].Replace('TYPE=', '').Replace(';', '').Replace(' ', '').trim() 
        $ori = $d[$i+2].Replace('AZIMUT="', '').Replace('"', '').Replace('PARENT=;', '0;').Replace(' ', '').trim() 
        $rows += $("{0};{1};{2}" -f $typ,$pos,$ori)            
    } 
}

$rows

sc -path ZGM_VisO_biediEX.csv -value $rows																			# Write output to a file.
(gc ZGM_VisO_biediEX.csv | select -Skip 1) | sc ZGM_VisO_biediEX.csv

