added a condition to check if the resulting Data frame is Null, then do nothing
changed the function to write a DB and a CSV file of the analysis, cleaned the script and reduced the printing during the analysis to lower footprint