I am data mining a log file and exporting information successfully. What I am looking to do is put a few blank, empty, or some kind of line separator between each export within the data mining criteria the script finds. I currently have:
SET "_LogFile=C:\Test.log"
SET "_ResultFile=OutPut.txt"
SET "_MatchString_Begin=<Line Text="***********TEST************"
SET "_MatchString_End=</Report>"
SET "_Line#_Begin="
)
CALL :Main
( ENDLOCAL
EXIT/B
)
:Main
CLS
IF EXIST "%_ResultFile%" (
DEL /F /Q "%_ResultFile%"
)
COLOR 0F
ECHO.&ECHO.===== Processing =====&ECHO.
FOR /F "Delims=[]" %%# IN ('
Find /N "%_MatchString_Begin:"=""%" "%_LogFile%" ^| FIND "["
') DO (
ECHO. Found Match On Line %%#
SET /A "_Line#_Begin=%%#-1"
CALL :Output
)
COLOR 20
ECHO.&ECHO.===== Completed! =====
FOR /F tokens^=2^ delims^=^" %%I in ('type "%_ResultFile%" ^& ^> "%_ResultFile%" rem/') do (
>> "%_ResultFile%" echo(%%I
)
REN %_ResultFile% Trythis.csv
START TryThis.csv
GOTO :EOF
:Output
FOR /F "SKIP=%_Line#_Begin% Tokens=* usebackq" %%_ IN (
"%_LogFile%"
) DO (
ECHO(%%_
ECHO("%%_" | FIND /I "%_MatchString_End%" >NUL&&(
GOTO :EOF
)
)>>"%_ResultFile%"
GOTO :EOF
In my export I get:
AAA
AAA
AAA
BBB
BBB
BBB
CCC
CCC
CCC
Would be nice to see:
AAA
AAA
AAA
---
BBB
BBB
BBB
---
CCC
CCC
CCC
A is one block that is exported, B is another Block Exported, C is another block exported. They currently all merge line after line. Would be nice to a separator in between each block exported.
Any suggestions would be MUCH appreciated!