← Back to Week 4

CSV ↔ Transaction Mapping

Each line in transactions.csv is one transaction. Five values, separated by |. Reading turns a line into an object; writing turns an object into a line.

transactions.csv → Transaction object
transactions.csv
Split the selected line by |
date
parsed as a LocalDate
time
parsed as a LocalTime
description
kept as a String
vendor
kept as a String
amount
parsed as a double
new Transaction
date
time
description
vendor
amount
Transaction → transactions.csv
Join the five values with | between them
(click “Join” to see the line that will be written)
transactions.csv — after the append
Date and time come in as text. The file stores strings like 2023-04-15 and 10:13:25. Your code has to convert those strings into LocalDate and LocalTime objects before they can be used for comparisons or formatting.
The delimiter is a pipe, not a comma. Even though the file is called .csv, the separator is |. Splitting on the wrong character is the most common load-bug.

Reading runs once at startup — every line becomes a Transaction and goes into your in-memory list. Writing happens every time the user adds a deposit or payment — one line appended per transaction.

← Menu Flow Map Deposit vs Payment Sign →