From 7294780e765ead8060003196955109a82b91e740 Mon Sep 17 00:00:00 2001 From: Trevor Bergeron Date: Thu, 23 Jul 2020 22:07:39 -0400 Subject: [PATCH] use csv writer library --- bot_commands.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bot_commands.py b/bot_commands.py index 6a983f0..86b0787 100644 --- a/bot_commands.py +++ b/bot_commands.py @@ -1,6 +1,7 @@ # coding=utf-8 from asyncio import Lock +import csv import logging from os import fsync, rename @@ -117,8 +118,9 @@ async def _process_request(self, ticket_type): tokens[h] = self.event.sender filename_temp = filename + ".atomic" with open(filename_temp, "w") as f: + csv_writer = csv.writer(f) for key in tokens.keys(): - f.write("%s,%s\n" % (key, tokens[key])) + csv_writer.writerow([key, tokens[key]]) f.flush() fsync(f.fileno()) rename(filename_temp, filename)