Aggregate a CSV Stock Manifest

Use csv.DictReader on the supplied CSV text with required product and quantity headers. Return total integer quantities by trimmed product name. Combine repeated products, support quoted commas, and skip rows with blank products, invalid integer quantities or negative quantities. Zero is valid. Missing required headers returns None; headers with no data returns {}.

Difficulty: intermediate

Examples

  • ["product,quantity\nrice,2\nbeans,3\nrice,4\n"]{"rice":6,"beans":3}

Your solution

Python

Results

Python starts when you run or submit this challenge.

Back to Lesson