mirror of
https://github.com/marcogll/telegram_expenses_controller.git
synced 2026-01-13 21:35:15 +00:00
feat: Implement core application structure, AI extraction, persistence, and Telegram bot modules with updated configuration and dependencies.
This commit is contained in:
23
app/integrations/exporters.py
Normal file
23
app/integrations/exporters.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
Functions for exporting data to other formats or systems (e.g., CSV, Google Sheets).
|
||||
"""
|
||||
import csv
|
||||
import io
|
||||
from typing import List
|
||||
from app.schema.base import FinalExpense
|
||||
|
||||
def export_to_csv(expenses: List[FinalExpense]) -> str:
|
||||
"""
|
||||
Exports a list of expenses to a CSV formatted string.
|
||||
"""
|
||||
output = io.StringIO()
|
||||
writer = csv.writer(output)
|
||||
|
||||
# Write header
|
||||
writer.writerow(FinalExpense.__fields__.keys())
|
||||
|
||||
# Write data
|
||||
for expense in expenses:
|
||||
writer.writerow(expense.dict().values())
|
||||
|
||||
return output.getvalue()
|
||||
Reference in New Issue
Block a user