
Build a Python CSV Checker That Reports Problems Before Changing DataPython · INSIGHTA CSV checker is a useful first automation project because it separates inspection from modification. Begin by reporting problems, then decide whether any corrections can be applied safely. Silent changes make errors harder to investigate.
Define the input contract
Use a fictional workshop register with identifier, session code, and attendance count. Specify required columns, permitted values, and whether blank cells are allowed. Keep a small example file beside the program.
Validate one row at a time
Check missing identifiers, invalid numbers, and unexpected session codes. Record the row number and a clear description of each issue. A message such as “row 8: attendance count is not a whole number” is more useful than “bad data”.
Keep raw data unchanged
Write the report to a separate file. If you later add corrections, preserve the original and record each transformation. Do not replace an unknown count with zero merely to make parsing succeed.
Test different failures
Create files with missing columns, duplicate identifiers, empty rows, and quoted text containing commas. Use the language’s CSV facilities rather than assuming that splitting every line on commas handles the format.
Finish with a summary showing rows inspected, issues found, and whether the file passed the agreed rules. A passing file is valid against those rules; it is not proof that every real-world value is true.
Technical reference: Python’s CSV module documentation. A portfolio version should include fictional input files, expected reports, and instructions for running the checker.
Created with AI assistance for JobJet. Illustrative exercises use fictional data; no employer outcomes are promised.