The task and original case

Build a CSV importer that treats quoted commas as data. The small file looks simple enough to split manually, which makes it a useful parsing exercise. Your deliverable should show the original input, parsed fields and a clear decision about malformed records.

Original practice inputs and intended output
Case elementValue or requirement
InputsHeader name,note; row "Lee, Ana","first, second".
BuildA CSV import utility with quoted, empty and malformed-row cases.

This is an original invented exercise. It is independent practice, with no employer assessment or open-vacancy claim. Download the inputs, attempt your own result, then open the separate answer key.

Build a result another person can follow

Keep the raw file and use Python's csv reader with a declared delimiter and quote character. Python documents this parser and the newline handling needed when opening CSV files. The fixture header is name,note; its data row contains a quoted name and a quoted note, each with an internal comma.

Read the header first, then check that every accepted row has the same field count. Do not assume parser success establishes your schema: an extra unquoted field may parse successfully but fail the two-column requirement. Preserve row numbers and report rejected rows. For strict malformed-quote handling, choose the parser's strict setting and still validate the resulting structure.

Sources[1]

Check the worked result

The parsed row has two fields: name “Lee, Ana” and note “first, second.” The internal commas remain part of their field values. Splitting the raw line on commas produces four pieces and retains quote fragments, so it cannot reproduce the intended table.

Write an output CSV using csv.writer and read it back. The second parse should preserve both values exactly, even if the writer chooses a slightly different quoting representation. Compare semantic fields as well as retaining the original bytes.

Make the failure visible

Test an empty note, a note containing an escaped quote and a row with an extra unquoted column. Record whether each is accepted or rejected and why. Avoid removing all quotation marks as cleanup: quotes inside a field can be real content. Do not claim that a valid parse makes imported text safe to execute as a spreadsheet formula.

Revise it and ask someone to reproduce it

Ask a peer to add a multiline quoted note and predict how many logical records it contains. Update the importer to preserve that record if it fits the declared schema. Re-run the original two-field fixture after the change, and document any limit such as maximum record size or accepted encoding.

  • The supplied quoted row parses into exactly two intact fields.
  • Round-trip writing and parsing preserve semantic values.
  • Extra fields and malformed quotes have declared error behavior.

Describe the work accurately

After completing your own version, you could adapt this project bullet: “Built a practice CSV import utility that preserves quoted fields, checks row shape and reports malformed records with source positions.”

Use Projects or Independent practice as the heading. Keep the input files, result and revision together. Describe only your own completed work; the invented numbers are model outputs, not employer results or measured business impact.