Skip to content

Commit

Permalink
use csv writer library
Browse files Browse the repository at this point in the history
  • Loading branch information
half-duplex committed Jul 24, 2020
1 parent 899ff5a commit c9b99ac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bot_commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding=utf-8

from asyncio import Lock
import csv
import logging
from os import fsync, rename

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c9b99ac

Please sign in to comment.