I have some basic stuff i wanted to write in a csv file, I can't seem to find any solution online so any help will be appreciated. Issue is when I try to write it doesn't write in seperate lines but rather all in one, I want it to write in the different columns of the csv file. Here's the code:
def save_to_csv(self, filename="accounts.csv"):
"""Save all accounts to a CSV file."""
with open(filename, mode="w", newline="", encoding="utf-8") as file:
writer = csv.writer(file)
writer.writerow(("Account ID", "Department", "Balance"))
for account in self.accounts:
writer.writerow((account.account_id, account.department_name,
account.balance))```