Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: Varsha.PindolaHello
I trying to count how many nulls appear in a string separated by ; eg xx is the string and I want to generate countofnulls column data below:
xxx xx ctn&month countofnulls
5 NULL;NULL;-0.5;-1;-1 7401254466-201209 2
5 NULL;NULL;-0.62;-1.24;-1.24 7407542466-201209 2
5 NULL;NULL;-0.83;-1.66;-1.66 7411211338-201209 2
5 NULL;NULL;NULL;NULL;NULL 584654525-201301 5
5 NULL;NULL;NULL;NULL;NULL 584655375-201301 5
5 NULL;NULL;NULL;NULL;NULL 7400060121-201407 5
5 NULL;NULL;NULL;NULL;NULL 7400181558-201309 5
5 NULL;NULL;NULL;NULL;NULL 7400262677-201303 5
5 NULL;NULL;NULL;NULL;NULL 7400515717-201402 5
5 NULL;NULL;NULL;NULL;NULL 7400515717-201407 5
Trying to achieve in a loop as shown below:
xxx = split ('1:XX',";")
yyy =len(xxx)
i = 0
countofnulls = 0
while (i < yyy)
{
do{
if isNull(xxx[i]) then
dontEmit = countofnulls + 1
else countofnulls = countofnulls
i = i + 1
}
emit xx, countofnulls
Please can you help
Kind regards
Varsha