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 7294780
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion 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,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)
Expand Down

0 comments on commit 7294780

Please sign in to comment.