I have a GIS input file that contains hundreds of the following lines (objects):
{
POSITION="[950.28174, 797.89899]";
TYPE="Saltlake";
AZIMUT="-25.722504";
PARENT="";
};
{
POSITION="[900.71307, 777.2226, -3.8146973]";
TYPE="Oak";
AZIMUT="-168.15758";
PARENT="";
};
POSITION means length, width, height [x,y,z]. Currently I use this powershell script to convert the input for the next tool:
$d=gc input.txt
$rows=@()
for ($i=0; $i -le $d.count -2; ++$i) {
if( $d[$i] -match "POSITION" ) {
$pos = $d[$i].Replace('POSITION="[', '').Replace(',',';').Replace(']";','').Replace(' ', '').trim()
$typ = $d[$i+1].Replace('TYPE=', '').Replace(';', '').Replace(' ', '').trim()
$ori = $d[$i+2].Replace('AZIMUT="', '').Replace('"', '').Replace('PARENT=;', '').Replace(' ', '').trim()
$rows += $("{0};{1};{2}" -f $typ,$pos,$ori)
}
}
sc -path output.csv -value $rows
The output.txt looks like this:
"Saltlake";950.28174;797.89899;-25.722504;
"Oak";900.71307;777.2226;-3.8146973e-006;-168.15758;
What happens is that the next conversion tool mistakes the AZIMUT value of "Saltlake" for its Z-Position, as there was no input given after the y-value in POSITION of input.txt - unlike for "Oak".
Now, is it possible to replace that missing Z-input space with a "0" and of course, don't replace it if a Z-Position is given?
The aim is to make output.txt look like this:
"Saltlake";950.28174;797.89899;0;-25.722504;
"Oak";900.71307;777.2226;-3.8146973e-006;-168.15758;