Finding number of empty cells in a table column?

To build on Number of Entries in a Column, I was wondering if there was a way to be able to count empty entries in a specific column. I thought I was getting close, but I keep getting an error.

``````table of random examples
c1	c2	c3	c4
1	2	3	4
--	--	--	5
1	--	--	6
2	3	--	7

every turn:
say "[empty-cells of table of random examples and c1 column].";
say "[empty-cells of table of random examples and c2].";
say "[empty-cells of table of random examples and c3].";
say "[empty-cells of table of random examples and c4].";

to decide which number is empty-cells of (tn - a table name) and (tc - a table column):
let temp be 0;
repeat through tn:
unless there is a tc entry, increment temp;
decide on temp;
``````

This can be done without the â€śto decideâ€ť function, but I was wondering if I was missing some syntax that would let empty-cells work?

Currently Iâ€™m getting

``````Problem. In the sentence 'if there is a tc entry'  , I was expecting to read a value, but instead found some text that I couldn't understand - 'a tc entry'.
Problem. You wrote 'if there is a tc entry'  , but 'a tc entry' is a value, not a reference to an entry in a table.
``````

Can I do better? Thanks!

The only way I see to do it in I7 is to handle the column manually:

``````	repeat through tn:
if tc is c1:
unless there is a c1 entry, increment temp;
if tc is c2:
unless there is a c2 entry, increment temp;
if tc is c3:
unless there is a c3 entry, increment temp;
if tc is c4:
unless there is a c4 entry, increment temp;
``````

This is a cobbled-together I6 definition that works:

``````To decide whether table cell exists in/from (TC - table column): (- ExistsTableLookUpEntry({-my:ct_0}, {TC}, {-my:ct_1}) -).

[...]

repeat through tn:
unless table cell exists in tc, increment temp;
``````

This gets into undocumented stuff and may not work in future releases.

2 Likes

Neat! Thanks especially for the I6 tip. I always appreciate the nudge to look into that more.