Every employee of ABC Corp receives an unlimited fuel allowance. Employees are required to send a record every time they fill up their vehicles. These records are appended to the same CSV file and processed at the month's end.
As a member of the digital operations team, your task is to read this CSV file and write the results to another CSV file. The output file should contain an entry for each employee with the following details:
You are given two string
arguments.
The input CSV file has n
lines, and each line takes the following form.
Column name | Ballerina type |
---|---|
employee_id | int |
odometer_reading | int |
gallons | decimal |
gas_price(USD) | decimal |
The output file should contain an entry for each employee, sorted in ascending order by the employee_id
. Each line takes the following form:
Column name | Ballerina type |
---|---|
employee_id | int |
gas_fill_up_count | int |
total_fuel_cost(USD) | decimal |
total_gallons | decimal |
total_miles_accrued | int |
n
in the input CSV file: 2 <= n <= 1000example01_input.csv
2312,230,18.561,4.56
2312,500,19.345,4.89
example01_output.csv
2312,2,179.23521,37.906,270
example02_input.csv
2413,04089,21.682,3.46
3423,06582,15.248,4.56
2413,04127,04.221,3.40
2413,04349,11.192,4.10
3423,06767,08.696,3.34
2413,04547, 09.197,2.90
example02_output.csv
2413,4,161.92962,46.292,458
3423,2,98.57552,23.944,185
ballerina/io
module to read/write csv filesSign up to Exercism to learn and master Ballerina with 58 exercises, and real human mentoring, all for free.