-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputclassroom.py
30 lines (27 loc) · 990 Bytes
/
inputclassroom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 14 00:01:34 2018
@author: lzt68
"""
import pandas as pd
import numpy as np
import datetime
from my_app.models import Classroom
dayofweek=['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
for i in range(1,14):
today=datetime.datetime.now()
targetday=today+datetime.timedelta(days=i)
dayofw=targetday.weekday()
data=pd.read_csv(dayofweek[dayofw]+'.csv',engine='python',encoding='utf-8')
for j in range(len(data)):
datapiece=list(data.loc[j])
for k in range(3,len(datapiece)):
if pd.isnull(datapiece[k]):
datapiece[k]=1
else:
datapiece[k]=0
cla=Classroom(building=datapiece[0],dayofweek=dayofw+1,\
date=datetime.datetime.strftime(targetday,"%Y-%m-%d"),\
room=datapiece[1],maxnum=int(datapiece[2]),\
status=str(datapiece[3:]))
cla.save()