Lessons / Part 3. Checking what an assistant tells you
20 A clean run is not a checked result
A merge that prints its row counts, unmatched keys and duplicates before anything is saved.
What people usually ask
Merge these two tables on sample ID and save the result.
What comes back
“Merged successfully, saved as merged.csv”, with 40 rows gone because the IDs in one file carry a trailing space.
Ask this instead
Attached: lab_results.csv and field_samples.csv. Both have a sample_id column and both have <column>.
Merge them on sample_id, and show these checks before saving anything:
1. Row count of each file before the merge, and of the result after it.
2. sample_id values present in one file and not the other, listed for each side, with the count.
3. Duplicate sample_id values in either file, with their rows.
4. The five rows where <column> differs most between the two files.
Do not drop, trim, rename or coerce anything to make the keys match. If the keys differ in format, show me three examples from each side and stop.
Write no file. Stop after the checks and wait for me.
Attach: the two CSV files.
Why it works: the counts and the unmatched keys show the rows a quiet inner join would have thrown away.
Drafted with Fable 5.1 from my notes; chosen and edited by me.