2/20
Sign inSign up free

1441. Totals per Column From a Real CSV

easy 10 XP ~10 minHands-on lab

Finance exports CSV files with a header row. Write /home/student/reports/sum_by.py:

python3 sum_by.py CSV KEY_COLUMN VALUE_COLUMN

Columns are chosen by header name. Values look like 1,234.50: the export quotes fields that contain a comma ("1,234.50"), and some text fields contain commas too. A sample is in /home/student/reports/sales.csv.

Task

  • Print one line per key, KEY TOTAL, with the total to exactly 2 decimals (emea 1234.50), sorted by key.
  • The result must be exact to the cent (no floating-point surprises).

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.