ABC 公司的每位员工都享有不限量的燃油补贴。员工每次给车加油后都需要提交一条记录。这些记录会被追加到同一个 CSV 文件里,并在月末统一处理。
作为数字运营团队的一员,你的任务是读取这个 CSV 文件,并把结果写入另一个 CSV 文件。输出文件应为每位员工包含一条记录,包含以下信息:
你会收到两个 string 参数。
输入 CSV 文件有 n 行,每行的格式如下。
| 列名 | Ballerina 类型 |
|---|---|
| employee_id | int |
| odometer_reading | int |
| gallons | decimal |
| gas_price(USD) | decimal |
输出文件应为每位员工包含一条记录,并按 employee_id 升序排列。每行的格式如下:
| 列名 | Ballerina 类型 |
|---|---|
| employee_id | int |
| gas_fill_up_count | int |
| total_fuel_cost(USD) | decimal |
| total_gallons | decimal |
| total_miles_accrued | int |
n: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 模块读写 csv 文件