You are tasked with applying a PII redaction tool to every CSV file in /opt/hr_data. The tool is redact_pii.py. For each CSV, create a sanitized copy with the same filename and relative path under /tmp/sanitized_hr_data. Create any missing directories in the destination tree. After running, you should have a parallel directory structure under /tmp/sanitized_hr_data containing the redacted copies.
Steps:
Discover all CSV files under /opt/hr_data recursively.
For each input file, determine the relative path to preserve the hierarchy (for example /opt/hr_data/dept1/records.csv -> dept1/records.csv).
Ensure the destination directory /tmp/sanitized_hr_data/<relative_path> exists; create directories as needed.
Run redaction for each file. A common pattern is:
redact_pii.py -i input_csv -o output_csv
You can implement this as a small shell loop, for example:
for f in /opt/hr_data/**/*.csv; do
rel=${f#/opt/hr_data/}
dst=/tmp/sanitized_hr_data/$rel
mkdir -p $(dirname $dst)
redact_pii.py -i $f -o $dst
done
Verification and deliverables:
For every input file, there is a corresponding sanitized copy under /tmp/sanitized_hr_data with the same filename.
A short log file at /tmp/sanitized_hr_data/process_log.txt that lists each input and its output, and a total count.
Do not modify the originals in /opt/hr_data.
Notes:
If redact_pii.py uses a different CLI (for example reads a file and writes to stdout), adapt the -i/-o usage accordingly but keep the same input-to-output mapping in /tmp/sanitized_hr_data.