Dear All,
I'm glad that I've also joined in this forum. Good work fellas...
Keep going...!
I am having a .csv file where I am reading the values with comma(,) as delimiter. After reading each and every values, I would like to check whether it is empty (say null or blank spaces). How to do this using awk command?
Code:
awk 'BEGIN {FS=","}
{ n=split($0,col_value,",")
for(i=1;i<=n;i++) {
if(length(col_value[i]) == 0) {
BLANK_COUNT = BLANK_COUNT+1
}
}
} END {print BLANK_COUNT}' sample.csv
Input File (sample.csv):
RollNo,Name,Mark1,Mark2,Mark3,Mark4
1,Tom,78,,67,98,56
2,Steve,85, ,56,65,67
3,John,96, , ,98
My code is returning 1 blank space for rollno:1 only. Whereas my requirement is to calculate the blank count which includes spaces also.
i.e.,
Rollno, Blank
1,1
2,1
3,2
Thanks in advance...!