#C14731. Summary Report Generator

    ID: 44413 Type: Default 1000ms 256MiB

Summary Report Generator

Summary Report Generator

You are given a CSV file's contents and a column name. Your task is to generate a summary report for the specified numeric column. The report should include:

  • The total number of data rows (excluding the header).
  • The average value of the column, formatted to two decimal places. In mathematical terms, if the column values are \(x_1, x_2, \dots, x_n\), then the average is \(\frac{\sum_{i=1}^{n}x_i}{n}\).
  • The maximum value of the column.
  • The minimum value of the column.

If the specified column does not exist in the CSV, output the error: Error: Column 'column_name' does not exist.

The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  1. The first line contains an integer n which represents the number of lines in the CSV file (including the header).
  2. The next n lines contain the CSV data. The first of these lines is the header.
  3. The line following the CSV data contains the column name for which the report is to be generated.

Example:

6
id,value
1,10
2,20
3,30
4,40
5,50
value

outputFormat

The program should print the summary report to standard output (stdout) in the following format:

Summary Report for column '':
Total number of rows: 
Average value: 
Maximum value: 
Minimum value: 

If the specified column does not exist, print:

Error: Column '' does not exist.
## sample
6
id,value
1,10
2,20
3,30
4,40
5,50
value
Summary Report for column 'value':

Total number of rows: 5 Average value: 30.00 Maximum value: 50 Minimum value: 10

</p>