Tools · Python and Bash for security automation · 24 / 26
A blank cell is not the number zero
An empty CSV cell is missing. The digit 0 is a value. Write which one you saw, and do not count a blank as zero.
A blank cell is an empty field
A data row can leave a column empty. The commas are still there, so the column exists, and the value is absent. Absent is not the character 0, and it is not a count of nothing you are allowed to add to other counts.
Quote the raw row when the emptiness matters. A spreadsheet that turns a blank into 0 has changed the output. Say so if that conversion happened.
The digit 0 is a printed value
A cell that contains 0 is a zero the script printed. It can sit in the same column as a blank on another row. Those rows are not the same fact. One has a number. The other has no number.
Do not add a blank into a sum as zero unless you write that you chose that substitution. The script did not print the substitution.
What the case file should show
For each cited row, write the cells you have, and write blank where the cell was empty. A total that skips blank rows should say it skipped them. A total that treats them as zero should say that was your step, not the script.
Lab: an empty count filed as zero
The lab CSV has a header count and two data rows. The first data row ends with an empty count cell. The second data row has count 0. A draft adds them as 0 plus 0 and says both rows reported zero.
The note says the first count is blank and the second count is 0. Only the second row printed a zero. The blank is not folded into that zero.
header: ip,count row A: 203.0.113.10, row B: 198.51.100.20,0 write: A blank, B zero not: both rows reported 0
Diagram
Keep a blank out of the zero
- Blank cell
The column is present and the value is absent.
203.0.113.10,
- Digit 0
The script printed a zero.
198.51.100.20,0
- A sum
Say if you turned blanks into zeros.
that step is yours
- The file
Leave the raw row quoted.
do not rewrite the comma
Check yourself
1. A data row ends with a comma and nothing after it. What is the last field?
2. The next row has the digit 0 in that column. What do you have?
3. You want a sum and one cell is blank. What has to be true of that sum?