diff --git a/bot_commands.py b/bot_commands.py index 6a983f0..7e6df58 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,8 @@ async def _process_request(self, ticket_type): tokens[h] = self.event.sender filename_temp = filename + ".atomic" with open(filename_temp, "w") as f: - for key in tokens.keys(): - f.write("%s,%s\n" % (key, tokens[key])) + csv_writer = csv.writer(f) + csv_writer.writerows(tokens.items()) f.flush() fsync(f.fileno()) rename(filename_temp, filename)