count number of nonempty columns in row

Hi,
Suppose i have a inputfile in csv format.
How to use awk to count 'the number of nonempty columns in each row' minus one, and add the value as a new column in the end

For cosmetic reason, it's even better to include a descriptive label for the last column in the first row.

for example, i want to convert

London,a,b,c,,,,->London,a,b,c,,,,,3
York,a,b,,,a,a ->York,a,b,,,a,a,4

root@isau02:/data/tmp/testfeld> cat infile
London,a,b,c,,,,
York,a,b,,,a,a
root@isau02:/data/tmp/testfeld> awk -F, '{z=0; for (x=2; x<=NF; x++) {if ($x != "") {z++} } {print $0","z} }' infile
London,a,b,c,,,,,3
York,a,b,,,a,a,4
#! /usr/bin/perl
open FH,"<a.txt";
while(<FH>){
	chomp;
	my @tmp=grep {$_} split(",",$_);
	print $_,",",$#tmp,"\n";
}
awk -F"," '{
        n=-1
        for(x=1;x<=NF;x++)
                if($x !="")
                        n++
        print $0","n
}' b