I'm stuck on a statement that I've already used multiple times with other delimiters. I have to process a three-line TXT file, each line contains 26 fields delimited by quotes. This is the file in which the second set is empty, it's a possible case:
ID="a1i7Q000000gTynQAE" Machine="TEST" Dept="TEST" ExecutionDate="2023/11/17"
Set 1="O14" Time="2023/11/17 18:33:09" MeasurementMode="Rad" A1="40.96" A2="41.65" A1Lenght="177" n1="133.75" C1="527" CAD="2.48" LAT="4.43" L="23.88" RoN="12.52" Diam="5.23"/
Set S="152" Time="2023/11/17 18:33:09" MeasurementMode="Deg" A1="NaN" A2="NaN" A1Lenght="NaN" n1="132.14" C1="NaN" CAD="NaN" LAT="NaN" L="NaN" RoN="NaN" Diam="NaN"/
On the first pass I have to extract data %%A, %%H, %%J, %%L, %%N, %%P and so on ignoring the first row, on the second pass I have to ignore the first two rows.
The expected output for result1.txt is
a1i7Q000000gTynQAE
"VV_A1_c" : 40.96
"VV_j32_a" : 41.65
177
.....
The command lines I'm using are the following:
for /f tokens^=1-26^ skip^=1^ delims^="^ %%A in ("out1.txt") do (
ECHO %%~A >>result1.txt
ECHO "VV_A1_c" : %%~H >>result1.txt
ECHO "VV_j32_a" : %%~J >>result1.txt
ECHO %%~L >>result1.txt
.....
and
for /f tokens^=1-26^ skip^=2^ delims^="^ %%A in ("out1.txt") do (
ECHO %%~A >>result2.txt
ECHO "VV_A1_c" : %%~H >>result2.txt
.....
...but the result is always "Sintax error" or "not expected" no matter how I set the ^ delimiters. Please can anyone tell me where I'm wrong?
Another question: if the fields become 30 what letters must I use after %%Z?
Tried to get it working using Windows batch:
output:
But
skip=need too much work-around and i am no-where near your expected output.Maybe a simpler approach would be PowerShell:
output:
For your expected output this might start with:
output:
And, a (steep?) learning curve towards PowerShell, which I am not too familiar with...