Skip to content

Commit

Permalink
feat: save data in csv file
Browse files Browse the repository at this point in the history
  • Loading branch information
Yejining committed Feb 13, 2020
1 parent 23461cd commit d1b2dd7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/input/database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from datetime import datetime
from operator import eq

import pandas as pandas

from database.lib import MYSQL
import database.constant as dbconstant
from src.exception import Error
Expand Down Expand Up @@ -91,7 +93,7 @@ def get_dbconn(self):
def get_id(self):
if self.checkBox_dbid.isChecked() is not True:
return datetime.now().strftime("%y%m%d%H%M%S")
if self.is_valid_id():
if self.on_id_apply():
return self.lineEdit_dbid.displayText()

def is_existing_id(self):
Expand All @@ -108,6 +110,7 @@ def save(self, result, parser):
width, height = parser.get_card_size()
horizontal_margin, vertical_margin = parser.get_margins()
id = self.get_id()
data_list = []

for count in range(len(result.ranges)):
start, end = result.ranges[count]
Expand Down Expand Up @@ -150,4 +153,8 @@ def save(self, result, parser):
}

dbconn.insert(table=dbconstant.TABLE, data=tuple)
data_list.append(tuple)

path = "Z:\\paper_workspace\\EuroVis_2020_short\\participant_data_csv\\%s.csv" % id
pandas.DataFrame(data_list).to_csv(path, index=False)

0 comments on commit d1b2dd7

Please sign in to comment.