|I am a novice in scripting, but would like help in creating a batch script that will help me clean some data.|
Basically i have data in a flat file, where by the field are seperated by pipes. Each line in the dat file represent a specific client. In Each line there should be 50 fields delimited by a pipe.
I know there should be 50 fields, thus 49 Pipes. I have come accross instances where some lines have less fields or more that 50 fields.
I would like to carry out some data cleansing so I need a script that will count the pipes and tell me which line falls short, or over shoots the 49 Pipes. It would ideally output to a .txt file the findings, ie
Line 3, 47 pipes
Line 234, 56 pipes
So far had use the script below but it gives me the total pipes in the file.
@echo off & setLocal EnableDELAYedExpansion
set /p str= < pam.dat
set /p C=char to count ? :
if !str:~0^,1! equ !C! (
set /a N+=1
if "!str:~1!" neq "" (
echo !N!> result.txt