return the date out of a processing function

This commit is contained in:
2021-10-22 22:44:56 -06:00
parent 9d081a7a48
commit 381d8ca620
+9 -3
View File
@@ -1,6 +1,8 @@
#!/bin/python
"""
process fdx excel files into existing sqlite3 database
processREPORTNAME functions all expect a file and database connection
as arguments and return a date and error message if there is one
standalone usage fdxtools TYPE INFILE DATABASE where TYPE is the
report type, ie dsw, INFILE is an excel file, DATABASE is an sqlite file
"""
@@ -114,10 +116,10 @@ def processDsw(file, database):
# check if records already exist and then add records if not
if checkDate(database, reportDate):
print("we have already processed " + reportDate)
return reportDate, "we have already processed " + reportDate
else:
extractDsw(srcSheet, database, reportDate)
return reportDate, None
def main():
# get filename and database rom cmdline
@@ -133,7 +135,11 @@ def main():
sys.exit('database could not be opened, does it exist')
if args.type == 'dsw':
processDsw(args.inFile, conn)
date, error = processDsw(args.inFile, conn)
if not error:
print(date)
else:
print(error)
else:
print('type not found or not entered')