I am pretty new to batch file scripting.
I have to read data from the CSV file. Luckily I find a way to read.
But now struck with one more hurdle.
While reading CSV file I need to give warning for empty values of mandatory fields.
Given below is example of CSV file.
Example:
1,'EMPTY FIELD','abc','efg','tiger'
2, '172.16.2.22','xyz','str','lion'
Mandatory field is ipaddress. If that column is empty or null I need to give alert.
Batch file:
@echo off
SETLOCAL EnableDelayedExpansion
FOR /f "usebackq tokens=1-6* delims=, " %%a in ("template.csv") do (
set sno=%%a
set ipaddress=%%b
set username=%%c
set password=%%d
set port=%%e
set domain=%%f
IF !ipaddress! == [] ECHO is empty
ECHO !sno!, !ipaddress!, !username!, !password!, !port!, !domain!
)
pause
To check the values is null or not I tried this:
IF !ipaddress! == [] ECHO is empty
But this IF condition is not working.
EMPTY FIELDor does the line actually look like1,'','abc','efg','tiger'? Or does the line look like1,'abc','efg','tiger'?