Code:
$ cat conf
id,Numeric(2),NOT NULL
name,String(20)
state,String(10),NOT NULL
street_No,Numeric(4)
$ cat data
abc,john,MI,201
22,Lilly,CA,405
33,Richard,CA,21Q
444,Reet5,NY,258
55,Taylor,GI,3333
66,Merry,,3333
77,,,22
$ awk -F "," 'NR == FNR {h = (h == "") ? $1 : (h FS $1); gsub("[)(]", "-", $2); split($2, a, "-"); d[NR] = a[1]; l[NR] = a[2]; n[NR] = ($3 == "NOT NULL") ? 1 : 0; next}
FNR == 1 {print h > "goodrec"; print h > "badrec"}
{for(i = 1; i <= NF; i++)
{if(((d[i] == "Numeric" && (($i + 0) == $i || $i == "")) || d[i] == "String") && (length($i) <= l[i]) && (length($i) >= n[i]))
{f = 1} else {f = 0};
if(f == 0) {print $0 > "badrec"; b++; next}} print $0 > "goodrec"; g++}
END {print "Parsing is Success";
print "Count of Goodrec : " g;
print "ount of badrec : " b;
print "Validated records are found on the path \"/user/hduser/Dataparse\""}' conf data
Parsing is Success
Count of Goodrec : 2
ount of badrec : 5
Validated records are found on the path "/user/hduser/Dataparse"
$ cat goodrec
id,name,state,street_No
22,Lilly,CA,405
55,Taylor,GI,3333
$ cat badrec
id,name,state,street_No
abc,john,MI,201
33,Richard,CA,21Q
444,Reet5,NY,258
66,Merry,,3333
77,,,22
$