rewe-vereinscheine-fetcher/csv_exporter.py

18 lines
629 B
Python
Raw Permalink Normal View History

2023-05-15 09:30:56 +02:00
from verein import Verein
2023-05-15 10:32:52 +02:00
TABLE_HEADING = "account_name,address,post_code,city,total_balance,available_balance,redeemed"
2023-05-15 09:30:56 +02:00
def export_vereine(vereine: [Verein], export_filename: str):
export_string: str = TABLE_HEADING + '\n'
for verein in vereine:
export_string += line_for_verein(verein) + '\n'
with open(export_filename, 'w') as export_file:
export_file.writelines(export_string)
def line_for_verein(verein: Verein):
2023-05-15 10:32:52 +02:00
return f'"{verein.account_name}","{verein.address}",{verein.post_code},"{verein.city}",' \
f'{verein.total_balance},{verein.available_balance},{verein.redeemed}'