Reordering comments and functions

This commit is contained in:
Stefano Assenzo 2023-01-06 18:33:24 +00:00
parent 02afe8bace
commit 607d371534
2 changed files with 105 additions and 100 deletions

View File

@ -1,8 +1,8 @@
import os
from imbox import Imbox
from dotenv import load_dotenv
from imbox import Imbox
import traceback
import time
import os
# Load .env file
load_dotenv()

View File

@ -4,6 +4,7 @@ import openpyxl as xl
import datetime
import pymongo
import urllib
import time
import os
load_dotenv() #Load .env file
@ -15,33 +16,37 @@ database = client["website-class"] #Database name
collection = database["school-time-table"] #Collection school time table current
collection_archive = database["archive-school-time-table"] #Collection school time table archive
x = collection.delete_many({}) #Delete all documents in collection (school-time-table)
def recheck():
time.sleep(10)
update_time_school()
# Load excel file
namefile_xlsx = "attachments/school_time.xlsx"
workbook = xl.load_workbook(filename=namefile_xlsx)
ws = workbook.active
def update_time_school():
# Load excel file
namefile_xlsx = "attachments/school_time.xlsx"
workbook = xl.load_workbook(filename=namefile_xlsx)
ws = workbook.active
#Date
current_time = datetime.datetime.now()
day = str(current_time.day)
month = str(current_time.month)
year = str(current_time.year)
hour = str(current_time.hour)
minute = str(current_time.minute)
long_date = day + "-" + month + "-" + year + " " + hour + ":" + minute
#Date
current_time = datetime.datetime.now()
day = str(current_time.day)
month = str(current_time.month)
year = str(current_time.year)
hour = str(current_time.hour)
minute = str(current_time.minute)
long_date = day + "-" + month + "-" + year + " " + hour + ":" + minute
#Create collection
mydict = {
#Create collection
mydict = {
"Date": long_date,
"School Subject": [],
"Teacher": [],
}
x = collection.insert_one(mydict) # Add collection on collection (school-time-table)
x = collection_archive.insert_one(mydict) # Add collection on collection (archive-school-time-table)
}
x = collection.delete_many({}) #Delete all documents in collection (school-time-table)
x = collection.insert_one(mydict) # Add collection on collection (school-time-table)
x = collection_archive.insert_one(mydict) # Add collection on collection (archive-school-time-table)
#Search my class in excel file and add in MongoDB
for row in range (1, 100):
#Search my class in excel file and add in MongoDB
for row in range (1, 100):
# column B ~ column F
for column in range (1, 100):
cell = ws.cell(row, column)
@ -117,4 +122,4 @@ for row in range (1, 100):
}
)
os.remove(namefile_xlsx) #Delete excel file
os.remove(namefile_xlsx) #Delete excel file