From 0589c7fce5e5d7c745bdd50c0a7154077ede5725 Mon Sep 17 00:00:00 2001 From: Eric Phillips Date: Tue, 26 Oct 2021 01:19:04 -0600 Subject: [PATCH] name change from appendLedger to insertData --- flaskfdx/fdxsql.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/flaskfdx/fdxsql.py b/flaskfdx/fdxsql.py index 9fc58dd..7ca5126 100644 --- a/flaskfdx/fdxsql.py +++ b/flaskfdx/fdxsql.py @@ -23,7 +23,7 @@ def openDatabase(database): return conn -def appendLedger(conn, table, values): +def insertData(conn, table, values): """ add values to sqlite3 database """ @@ -32,9 +32,19 @@ def appendLedger(conn, table, values): c.execute('INSERT INTO {} VALUES ({})'.format(table, holders), values) conn.commit() +def sanatizeTotals(values): + """ + checks cells and replaces empty string with 0 + """ + +def sanatizeWorkarea(values): + """ + checks indexes 6+ and replaces empty string with 0 + """ + def extractDsw(srcSheet, conn, reportDate): """ - get dsw data from srcSheet and call appendLedger with values + get dsw data from srcSheet and call insertData with values """ # we dont extract data until we find a particular spot in the worksheet # there may be a search or other better way to do this @@ -51,7 +61,7 @@ def extractDsw(srcSheet, conn, reportDate): srcSheet.cell(i,14).value, srcSheet.cell(i,20).value, srcSheet.cell(i,18).value, srcSheet.cell(i,32).value, srcSheet.cell(i,33).value, srcSheet.cell(i,34).value) - appendLedger(conn, 'totals', values) + insertData(conn, 'totals', values) i += 1 values = ('terminal', reportDate, srcSheet.cell(i,6).value, srcSheet.cell(i,7).value, srcSheet.cell(i,8).value, @@ -60,7 +70,7 @@ def extractDsw(srcSheet, conn, reportDate): srcSheet.cell(i,14).value, srcSheet.cell(i,20).value, srcSheet.cell(i,18).value, srcSheet.cell(i,32).value, srcSheet.cell(i,33).value, srcSheet.cell(i,34).value) - appendLedger(conn, 'totals', values) + insertData(conn, 'totals', values) #we're done so exit break # get the individual route totals, need to figure a way to get skip double trip lines and get times for drivers on same @@ -79,7 +89,7 @@ def extractDsw(srcSheet, conn, reportDate): srcSheet.cell(i,12).value, srcSheet.cell(i,2).value, srcSheet.cell(i,24).value, srcSheet.cell(i,13).value, srcSheet.cell(i,19).value, srcSheet.cell(i,17).value) - appendLedger(conn, 'dsw', values) + insertData(conn, 'dsw', values) if 'Svc' in srcSheet.cell(i,0).value: extract = True