refactoring

This commit is contained in:
frankknoll
2022-11-22 12:40:26 +01:00
parent 134a133da1
commit e87fe0c8ba
21 changed files with 692 additions and 731 deletions

39
src/IOUtils.py Normal file
View File

@@ -0,0 +1,39 @@
import os
class IOUtils:
@staticmethod
def saveDataFrame(dataFrame, file):
# IOUtils.saveDataFrameAsExcelFile(dataFrame, file)
# IOUtils.saveDataFrameAsHtml(dataFrame, file)
IOUtils.saveDataFrameAsJson(dataFrame, file)
@staticmethod
def saveDataFrameAsExcelFile(dataFrame, file):
IOUtils.ensurePath(file)
dataFrame.to_excel(file + '.xlsx')
@staticmethod
def saveDataFrameAsHtml(dataFrame, file):
IOUtils.ensurePath(file)
dataFrame.reset_index().to_html(
file + '.html',
index = False,
table_id = 'batchCodeTable',
classes = 'display',
justify = 'unset',
border = 0)
@staticmethod
def saveDataFrameAsJson(dataFrame, file):
IOUtils.ensurePath(file)
dataFrame.reset_index().to_json(
file + '.json',
orient = "split",
index = False)
@staticmethod
def ensurePath(file):
directory = os.path.dirname(file)
if not os.path.exists(directory):
os.makedirs(directory)