I want to count the lines in my input csv file , success and error files and based on the condition i need to write the status file
if the success count equals to the input count then
echo List.csv,%Counter%,%SuccessCounter%,%date% %time%,True >> in the statusfile
else
echo List.csv,%Counter%,%SuccessCounter%,%date% %time%,false >> in the statusfile
if the error count > 1
send email to user by attaching the error file
I am using this code in bat file to write a file. i set the file path in the %statusfile%, my code not write file neither in if part nor else part
if %Counter% equ %SuccessCounter% (
echo List.csv,%Counter%,%SuccessCounter%,%date% %time%,True >> %statusfile%
) else (
set partUpload_flag=1
echo List.csv,%Counter%,%SuccessCounter%,%date% %time%,False >>%statusfile%
)
this is the code where i'm getting counter, i try printing the counter , getting the line count correct only. also i'm getting first line in the file.
set statusfile=%rootpath%Input\Status.csv
echo FileName,TotalLines,processedLines ,DateTime,status > %statusfile%
set /a Counter =0 FOR /F "DELIMS=, TOKENS=1,2" %%p IN ( %rootpath%extras\Input.csv) Do
( set "line=%%a" set "line="!line:,=","!""
set /a Counter +=1 )
Also one more thing, the condition worked fine for me before i add some more lines to them. once after adding the more lines this stop working, even after removing them it is not working .. the added lines are as below. i added this in the else part.
if %ErrorCounter% gtr 1 (
set success_flag=0
set Attachment= %Attachment% -attach %rootpath%extras\error.csv
echo %date%%time% ERROR:Error found in records : %ErrorCounter% lines >> %logpath%
)
How to fix the issue, as i'm new cant find the way to debug.