Add datetime module for naming output file
This commit is contained in:
parent
98007ce374
commit
815afe2e5f
@ -6,6 +6,7 @@ import os
|
||||
import numpy as np
|
||||
from order_items import possible_order_items
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
root= os.path.dirname(os.path.abspath(__file__))
|
||||
vscode_available = any(os.access(os.path.join(path, "code"), os.X_OK) for path in os.environ["PATH"].split(os.pathsep))
|
||||
@ -221,19 +222,23 @@ for line in dialog:
|
||||
now_pizzeria = not now_pizzeria
|
||||
|
||||
|
||||
# find all json files consisting of number (0.json, 1.json .... 123.json)
|
||||
files = [f for f in os.listdir(root + "/output_dialogs") if f.endswith(".json") and f[:-5].isdigit()]
|
||||
## find all json files consisting of number (0.json, 1.json .... 123.json)
|
||||
#files = [f for f in os.listdir(root + "/output_dialogs") if f.endswith(".json") and f[:-5].isdigit()]
|
||||
#
|
||||
## get name for next file (number higher than the highest number in the folder)
|
||||
#if len(files) == 0:
|
||||
# next_file = "0.json"
|
||||
#else:
|
||||
# next_file = str(max([int(f[:-5]) for f in files]) + 1) + ".json"
|
||||
#
|
||||
#
|
||||
## save to output_dialogs/next_file
|
||||
#with open(root + "/output_dialogs/" + next_file, "w", encoding="utf-8") as f:
|
||||
# json.dump(training_dict, f, indent=4, ensure_ascii=False)
|
||||
|
||||
# get name for next file (number higher than the highest number in the folder)
|
||||
if len(files) == 0:
|
||||
next_file = "0.json"
|
||||
else:
|
||||
next_file = str(max([int(f[:-5]) for f in files]) + 1) + ".json"
|
||||
next_file = datetime.now().strftime("%d-%m-%Y_%H-%M-%S") + ".json"
|
||||
|
||||
|
||||
# save to output_dialogs/next_file
|
||||
with open(root + "/output_dialogs/" + next_file, "w", encoding="utf-8") as f:
|
||||
json.dump(training_dict, f, indent=4, ensure_ascii=False)
|
||||
|
||||
|
||||
# remove temp/dialog_input.py
|
||||
|
Loading…
Reference in New Issue
Block a user