Mask emails for display, and suppress small groups

short · 35 min · Objective 5.3

Task

Mask customers' email addresses for a support screen, then publish survey respondent counts by age band and region with every group under ten suppressed.

Steps

  1. Save lab/mask/emails.csv with header customer_id,email_masked, for every customer in data/customers.csv: the address's first character, then ***, then the @ and the domain.
  2. Count survey respondents in data/survey.json for each combination of age band and region, and save lab/mask/survey-cells.csv with header age_band,region,respondents.
  3. Write every count below 10 as <10.

Verify

These checks run in a POSIX shell with Python 3: Terminal on macOS or Linux, and on Windows Git Bash (it comes with Git for Windows) or WSL. On Windows, python3 is often a Microsoft Store placeholder that prints “Python was not found”; run alias python3=py in Git Bash first.

grep -c '[*][*][*]@' lab/mask/emails.csv
awk -F, 'NR>1 && $2 !~ /^.[*][*][*]@/' lab/mask/emails.csv | wc -l
awk -F, 'NR>1 && $3=="<10"' lab/mask/survey-cells.csv | wc -l
awk -F, 'NR>1 && $3!="<10" {s+=$3} END {print "shown: "s}' lab/mask/survey-cells.csv

300 masked addresses and 0 left unmasked. 9 of the 20 cells are suppressed, and the published cells show 141 of the 200 respondents. Suppression alone is not enough if totals are published too: 200 minus 141 tells a reader how many are hidden, and a region's total minus its visible cells gives a suppressed cell back.

This is an independent study companion for CompTIA Data+ DA0-002 and is not produced by or endorsed by CompTIA.