So I have a function which will essentially run and generate a report and save it with args.current_date filename. The issue I am having is to remove the extension .json
from the filename being saved which really is not readable. Since I am passing dict
as args, I cannot use the strip()
method in order to do this. So far my function is follows :
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--current-date", action="store", required=False)
parser.add_argument("-p", "--previous-date", action="store", required=False)
args = parser.parse_args()
def custom_report(file_names, previous_data , current_data):
reporting = open('reports/' + args.current_date+ "-report.txt", "w")
reporting.write("This is the comparison report between the directories" " " + args.current_date +
" " "and" " " + args.previous_date + "\n\n")
for item in file_names:
reporting.write(item + compare(previous_data.get(item), current_data.get(item)) + "\n")
reporting.close()
It has saved the file as '2019-01-13.json-report.txt'. I want to be able to get rid of the '.json' aspect and leave it as '2019-01-13-report.txt'