CSV Sales Report

easy
Unit 8 · Dataclasses0/3 to milestone

Real CSV files have quoted fields with commas in them, blank lines and the occasional broken row. Splitting on commas yourself breaks on all of these. Use the csv module.

Implement sales_report(text) where text is CSV with a header row category,item,amount:

  • Sum amount per category. Amounts may be written like 1,250.50 inside quotes, so remove the commas.
  • Skip rows with a missing or non-numeric amount, or a blank category, and count them.
  • Return {"totals": {category: total}, "skipped": n}, with totals rounded to 2 decimal places and categories sorted alphabetically.
#csv#parsing#collections2 visible + 3 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
CSV Sales Report · TechGradify