Count columns that are non-empty per line

The file is similar to the attached.
Thousands of columns, delimiter is tab, with many columns containing free text and space separated.
I want to get the count of columns with non-empty entries.

eg.Col1=10, Col6=5, Col8=1
awk preferred

Any attempts / ideas / thoughts from your side?

awk -F "\t" '{ for(N=1; N<=NF; N++) if($N==""); {print NF}}'  ex.txt

This gives me NF=14, but I want the each col. in the file as header and another line with the number of non-empty lines for each.
So, not sure I am approaching this right.

How about

awk -F "\t" '
       {for (N=1; N<=NF; N++) if ($N!="") CNT[N]++}
END    {for (N=1; N<=NF; N++) print "col" N ":", CNT[N]
       }
' /tmp/ex.txt 
col1: 10
col2: 10
col3: 10
col4: 2
col5: 2
col6: 6
col7: 5
col8: 2
col9: 4
col10: 1
col11: 3
col12: 3
col13: 1
col14: 10
1 Like

Yes, that worked perfectly. Thank you!
So, let me understand your approach.
First, you are looking for Non-empty cells, and then making a count of such cells?

($N!="") CNT[N]++

Then you are printing

 print "col" N ":", CNT[N]

the col number and the count?

A request: Assuming the file has a header, how to modify such that instead of Col number, the ColHeader is printed?
many Thanks

It always helps to post samples, so people don't have to dream up some but can start working on a solution.

Would that be a one line header? No empty fields in it?

And yes, I count up a counter (array) per field, and, in the END section, print those.

The sample you posted earlier seems to have a header line. And DOS line terminators (<CR> = \015 = 0x0D = \r = ^M ). Try

awk -F "\t" '
        {sub ("\r","")
        }
NR == 1 {N = split ($0, HD); next
        }
        {for (N=1; N<=NF; N++) if ($N!="") CNT[N]++}
END     {for (N=1; N<=NF; N++) print HD[N] ":", CNT[N]
        }
' /tmp/ex.txt 
ID1: 9
ID2: 9
ID3: 9
Status1: 1
Status2: 1
Status3: 5
Status4: 4
Status5: 1
Status6: 3
..: 
..: 2
..: 2
..: 
StatusX: 2
1 Like

Thank you!