Put an analysis under version control and watch it change
Task
Write a small analysis script, commit it to a Git repository, change what it calculates, commit again, and use the history to show exactly what changed and when.
Steps
- Create
lab/vc, rungit initthere, and writelab/vc/count.py, which prints the number of orders indata/orders.csv. - Commit it with the message
count all orders. - Change the script so it counts only orders with a positive quantity, run it, and save the output to
lab/vc/output.txt. Commit with the messageexclude impossible quantities. - Save
git log --onelinetolab/vc/history.txtandgit diff HEAD~1 HEADtolab/vc/change.diff.
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.
wc -l < lab/vc/history.txt
grep -c 'exclude impossible quantities' lab/vc/history.txt
grep -c '^[+]' lab/vc/change.diff
cat lab/vc/output.txt
Two commits in the history, the second named as the change, a diff showing the lines that changed, and an output of 1997 -- the 2000 orders less the three with negative quantities. Anyone who asks why the count dropped by three can read the answer in the history.
This is an independent study companion for CompTIA Data+ DA0-002 and is not produced by or endorsed by CompTIA.