Build the workbench and prove the data is what it claims to be
Task
Install the course's tools, generate the practice data sets, make the raw data read-only, and write a first script that profiles a file the same way every time it runs. By the end you have a workbench where a mistake costs nothing and a record of what the data looked like when you started.
Steps
- Install Python 3 if you do not have it, and save the output of
python3 --versiontolab/bench/python.txt. On Windows, ifpython3prints that Python was not found, runalias python3=pyin Git Bash first. - Download
make-datasets.pyfrom the course's data page and runpython3 make-datasets.py --out data. - Count the data rows (not counting the header) in
data/orders.csvanddata/customers_raw.csv, and record them inlab/bench/counts.csvwith headerfile,rows, one row per file, using the file names exactly asorders.csvandcustomers_raw.csv. - Make the data read-only with
chmod a-w data/*.csv. Try to append a line todata/orders.csvwithecho x >> data/orders.csv, and record the outcome inlab/bench/readonly.txtaswrite refused: yesorwrite refused: no. - Write
lab/bench/profile.py, which prints the number of rows and columns indata/customers_raw.csv. Run it twice, saving the output tolab/bench/run1.txtandlab/bench/run2.txt.
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 'Python 3' lab/bench/python.txt
awk -F, '$1=="orders.csv" {print "orders: "$2}' lab/bench/counts.csv
awk -F, '$1=="customers_raw.csv" {print "customers_raw: "$2}' lab/bench/counts.csv
grep -c 'write refused: yes' lab/bench/readonly.txt
cmp lab/bench/run1.txt lab/bench/run2.txt && echo "same output both runs"
The orders file has 2000 data rows and the raw customer file 314, the append was refused, and the profile script printed exactly the same thing both times. That last line is the point of the workbench: a script gives the same answer every time, which a sequence of clicks does not. Make the folder writable again with chmod u+w data/*.csv only if you need to regenerate it.
Notes
Read-only files protect against the commonest accident in data work, overwriting the original while cleaning it. The later labs all write their results under lab/, never into data/.
This is an independent study companion for CompTIA Data+ DA0-002 and is not produced by or endorsed by CompTIA.