ABC Corp 的每位員工都能獲得無限的燃料補助。員工每次為車輛加油時,都必須提交一筆紀錄。這些紀錄會附加到同一個 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 檔案