Computing Staff
  • 14

How To Create Batch File To Extract Data From Excel To Txt

  • 14

Hello,
I m new here. I trying to create batch file. The purpose of this file it should retrieve specific data from the *.csv, example entire line that found percentage of 80 %. For example

Server Name Disk used Percentage
server A C 80 %
server B D 80 %
server C F 80 %
The entire row which containing of all 80 % should be export to text file.
My source of data would be *.csv or *.xls files.
Please advice me if this can done using batch file.

Share

4 Answers

  1. :: percent.bat 2020-11-12 17:59:01.36
    @echo off > OUT.TXT & setLocal enableDELAYedeXpansioN
    copy my.csv IN.TXT > nul
    for /f “tokens=1-5 delims= ” %%a in (IN.TXT) do (
    if %%d equ 80 echo.%%a %%b %%c %%d %%e
    ) >> OUT.TXT

    goto :eof

    • 0
  2. the source file is saved as *,cvs
    is not a filename.
    Do this and post the list:
    dir/b *.csv

    • 0
  3. Hello my apologise missed this..earlier…thanks for pointing…
    Here is output
    C:\capacity\percent>dir/b *.csv
    my_csv.csv
    when I run the percent.bat
    C:\capacity\percent>my_percent.bat
    The system cannot find the file IN.TXT.
    The above is the error output then I getting on…

    Thank you and appreciate your help….

    • 0
  4. :: percent.bat 2020-11-12 17:59:01.36
    @echo off > OUT.TXT & setLocal enableDELAYedeXpansioN
    copy my_csv.csv IN.TXT > nul
    for /f “tokens=1-5 delims= ” %%a in (IN.TXT) do (
    if %%d equ 80 echo.%%a %%b %%c %%d %%e
    ) >> OUT.TXT

    goto :eof

    • 0