bat to strip lines from a csv file

June 26, 2013 at 23:28:59
Specs: Windows 64
I am needing to create a bat file to read a csv file and strip anything that doesn't start with a "O" as first field.
or read a file and output everything that starts with a "O" into a seperate file

See More: bat to strip lines from a csv file

Report •


#1
June 27, 2013 at 01:03:18
::======  script starts here  ===============
:: split csv lines begin with O
:: Osplit.bat  2013-06-27 14:55:59.31
@echo off & setLocal enableDELAYedeXpansioN
@echo off > A.csv & @echo off > B.csv

:main
for /f "tokens=* delims= " %%a in (my.csv) do (
set S=%%a
set S=!S:~0,1!
  if !S! equ O (
    >> A.csv echo.%%a
    ) else (
    >> B.csv echo.%%a
  )
)
goto :eof
::======  script ends here  =================



Report •
Related Solutions


Ask Question