InferenceAI

Enter at least two characters to search.

Start free
Repository challenges

Repair a CSV ingestion contract

Feature · Intermediate · Data analytics · 35 minutes

Engineering ticket

Implement ingest(text) for CSV with headers id,amount_cents. Use a CSV parser. Strip whitespace from values. Accept rows only when id is nonempty and amount_cents is a nonnegative integer string. Keep the first valid row per id; count invalid and duplicate rows as rejected. Return {"rows": [[id, cents], ...], "rejected": count}, preserving accepted input order. The input always has the two required headers. Blank lines ignored by the CSV parser are not rejected rows.

Review rubric

  • Correctness on documented inputs
  • Tests and edge cases
  • Clear explanation of trade-offs

Reading the ticket and starter files is public. Sign in to save edits, run tests and submit evidence. Code-review quality requires human review.

Starter repository

README.md
# InferenceAI engineering lab

Read the ticket, inspect the files, reproduce the issue and implement the contract. Run visible tests while working. Submit checks protected cases. Explain your changes and limitations.
ingest.py
def ingest(text):
    return {"rows": [], "rejected": 0}
tests/test_ingest.py
import unittest
from ingest import *

class ContractTest(unittest.TestCase):
    def test_example(self):
        self.assertEqual(ingest("id,amount_cents\na,125\nb,bad\n"), {"rows": [["a",125]], "rejected": 1})