Link to home
Start Free TrialLog in
Avatar of Kishore_chintalpati
Kishore_chintalpati

asked on

DOS Findstr Command

I have a huge file containing statistics of certain operation. Each record has 3 columns with each column value seperated by a comma. I need to display only the columns with numerical values and ignore the columns which are either empty or have special charecters or string literals using DOS commands. Please help.
56787,"",""
375678,"dfyh","jhmfgy"

Open in new window

Avatar of Kishore_chintalpati
Kishore_chintalpati

ASKER

Urgent.
If all yo want to do is display data from the first column, then the following batch file will do the job.

Copy and paste the following code into Notepad and save it as PROCNUM.BAT in the same folder as your CSV file. Fire up a DOS session and enter the command:

   PROCNUM


@echo off
for /f "tokens=1-3 delims=," %%a in ('type columns.txt') do (
   echo %%a
)
If there is a possibility of numerical data appearing in any column, then this will display the numerical data in column format. (The 'SET COLUMNS=' line is followed by 12 spaces).

@echo off
set column=            
for /f "tokens=1-3 delims=," %%a in ('type columns.txt') do (
   echo %%a|findstr "[^0123456789]">NUL
   if errorlevel 1 echo %%a
   echo %%b|findstr "[^0123456789]">NUL
   if errorlevel 1 echo %column%%%b
   echo %%c|findstr "[^0123456789]">NUL
   if errorlevel 1 %column%%column%%%c
)
ASKER CERTIFIED SOLUTION
Avatar of t0t0
t0t0
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you brother... You rock !!