BasicFiles & CSV10 points

Peak power month of a region

A grid operator plans maintenance outside the busiest month of each region. Monthly consumption is stored in energy.csv for 2024 and 2025.

  • month: YYYY-MM
  • region: region name (for example Iberia or US Midwest)
  • mwh: electricity consumed that month in megawatt-hours (whole number)

Task: the first input line is a region (exactly as in the file), the second line a year such as 2025. Print two lines: Total MWh: T (sum over that region and year) and Peak month: M (V MWh) where M is the month with the highest consumption and V its value. If two months tie, print the earlier one. If there is no data, print No data on a single line instead.

Files your program can read

energy.csv145 lines
month,region,mwh
2024-01,Northern Europe,6492
2024-01,Iberia,3956
2024-01,US Midwest,8847
2024-01,South Asia,4739
2024-01,East Africa,1638
2024-01,Patagonia,721
2024-02,Northern Europe,6529
...

Open them by name, for example open("energy.csv").

Sample test

Input

Iberia
2025

Expected output

Total MWh: 37134
Peak month: 2025-01 (3872 MWh)

Your answer is also checked against 4 hidden tests.