include exported at field
This commit is contained in:
parent
1a6260b90b
commit
4973d4c61a
1 changed files with 6 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import csv
|
||||
import datetime
|
||||
import pathlib
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
|
@ -20,9 +21,11 @@ class CSVRateWriter(RateWriter):
|
|||
def write_rates(self, rates: ExchangeRates) -> None:
|
||||
with open(self.output_file_path, mode="w") as csv_file:
|
||||
csv_writer = csv.writer(csv_file)
|
||||
csv_writer.writerow(["from_currency", "to_currency", "rate", "rate_date"])
|
||||
csv_writer.writerow(
|
||||
["from_currency", "to_currency", "rate", "rate_date", "exported_at"]
|
||||
)
|
||||
|
||||
# Write the exchange rate data
|
||||
exported_at = datetime.datetime.now()
|
||||
for rate in rates._rate_index.values():
|
||||
csv_writer.writerow(
|
||||
[
|
||||
|
|
@ -30,5 +33,6 @@ class CSVRateWriter(RateWriter):
|
|||
rate.to_currency.value,
|
||||
rate.rate.amount,
|
||||
rate.rate_date.strftime("%Y-%m-%d"),
|
||||
exported_at.isoformat(timespec="seconds"),
|
||||
]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue