d1.py
______________________________________________
#-*-coding:utf-8-*-
import time
import datetime
filename='record20180911.txt'
x1,x2,x3,x4,x5,x6=[],[],[],[],[],[]
with open(filename,'r') as f:
lines=f.readlines()
for line in lines:
value=line.strip().split()
x1.append(value[0]) #data
x2.append(value[1])
x3.append(value[3]) #source
x4.append(value[4]) #engneer
x5.append(value[5])
x6.append(value[23])
d=x1[0]
x33=x3[0]
x55=x4[0]
x66=x4[0]
#print name
n1=x6[1]
n2=[n1]
for i in x6:
if i==n1:
continue
else:
n1=i
n2.append(i)
n22=[]
n222=[]
for i in n2:
j=i.split('&')
n22.append(j)
for i in range(len(n22)):
for j in n22[i]:
n222.append(j)
name={'xuguo':'張旭國','zqli':'李振強','minwang':'王敏','lijibin':'李積斌','hlzhang':'張海龍','fjjin':'金鳳娟','yangli':'李陽','jxsun':'孫繼先','yxzhang':'張永興','pingyan':'顏萍','bgju':'巨秉剛','kunyan':'顏昆','drlu':'逯登榮','syjin':'靳生玉','csluo':'羅春盛'}
n1=n222[0]
n2=n222[1]
n3=n222[2]
n4=n222[3]
n5=n222[4]
n6=n222[5]
n1=name.get(n1)
n2=name.get(n2)
n3=name.get(n3)
n4=name.get(n4)
n5=name.get(n5)
n6=name.get(n6)
#find time of BZY
TT1=[]
a,b,c='L134','SKYDIP','W51D'
for i in range(len(x3)):
if x3[i]==a:
TT1.append(x2[i])
TT2=[]
for i in range(len(x3)):
if x3[i]==b:
TT2.append(x2[i])
TT3=[]
for i in range(len(x3)):
if x3[i]==c:
TT3.append(x2[i])
TT=TT1+TT2+TT3
Ta=TT[0]
Tb=TT[len(TT)-1]
timeStruct=time.strptime(Ta,"%H:%M:%S")
strtime1 = time.strftime("%H:%M", timeStruct)
timeStruct=time.strptime(Tb,"%H:%M:%S")
strtime2 = time.strftime("%H:%M", timeStruct)
strtime=strtime1+'-'+strtime2
#find time of STOP
s1=x3[0]
tr1=x2[0]
s2=[s1]
tr2=[tr1]
tr22=[]
for i in range(len(x3)):
if x3[i]==s1:
continue
else:
s1=x3[i]
s2.append(x3[i])
tr2.append(x2[i])
tr22.append(x2[i])
s0='STOP'
Trr=[]
for i in range(len(s2)):
if s2[i]==s0:
start=tr2[i]
end=tr22[i]
strTime1=datetime.datetime.strptime(start,"%H:%M:%S")
strTime2=datetime.datetime.strptime(end,"%H:%M:%S")
strTime=(strTime2-strTime1).seconds
if strTime>=1800:
timeStruct1=time.strptime(start,"%H:%M:%S")
timeStruct2=time.strptime(end,"%H:%M:%S")
strTime1=time.strftime("%H:%M", timeStruct1)
strTime2=time.strftime("%H:%M", timeStruct2)
trr=strTime1+'-'+strTime2
Trr.append(trr)
else:
continue
#yin he hua juan
sta1=x2[0]
end1=strtime1
sta2=strtime2
end2=x2[-1]
timeStruct=time.strptime(sta1,"%H:%M:%S")
sta1=time.strftime("%H:%M", timeStruct)
timeStruct=time.strptime(end2,"%H:%M:%S")
end2=time.strftime("%H:%M", timeStruct)
Tyh1=sta1+'-'+end1
Tyh2=sta2+'-'+end2
Tyh=[Tyh1,Tyh2]
#############################################################
filename='slrecord20180911.asc'
x11,x13=[],[]
with open(filename,'r') as f:
lines=f.readlines()
for line in lines:
value=line.strip().split()
x11.append(value[0])
x13.append(value[2])
#delete chong fu data
k1=x13[0]
t1=x11[0]
k2=[k1]
t2=[t1]
for i in range(len(x13)):
if x13[i]==k1:
continue
else:
k1=x13[i]
aa=x11[i]
timeStruct=time.strptime(aa,"%H:%M:%S")
strTime=time.strftime("%H:%M", timeStruct)
k2.append(x13[i])
t2.append(strTime)
#time lian jie
T1=t2
T2=[]
for i in range(len(t2)):
if i==0:
continue
else:
T2.append(t2[i])
T2.append(' ')
T3=[]
for i in range(len(T1)):
TT=T1[i]+'-'+T2[i]
T3.append(TT)
#find time of bei ji qu
tt=[]
for i in range(len(k2)):
if k2[i]=='G120+20':
tt.append(T3[i])
#ke ti time and name
kk=[]
tk=[]
for i in range(len(k2)):
if k2[i].startswith('18')==True:
tk.append(T3[i])
kk.append(k2[i])
else:
continue
22.py
—————————————————————————————
#-*-coding:utf-8-*-
import sys
import docx
from docx.enum.text import WD_ALIGN_PARAGRAPH
import d1
reload(sys)
sys.setdefaultencoding('utf-8')
doc=docx.Document()
paragraph=doc.add_paragraph(u'青海觀測站13.7米望遠鏡運行狀況日報表')
paragraph.paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
table1=doc.add_table(rows=2,cols=1,style='Table Grid')
v1=d1.d
v1=str(v1)
hdr_cells=table1.rows[0].cells
hdr_cells[0].text=u'時間:'+v1
hdr_cells=table1.rows[1].cells
hdr_cells[0].text=u'望遠鏡名稱:13.7米毫米波射電望遠鏡'
table2=doc.add_table(rows=2,cols=2,style='Table Grid') #tian jia table
hdr_cells=table2.rows[0].cells
hdr_cells[0].text=u'基地總值班:巨秉剛'
hdr_cells[1].text=u'觀測助手:巨秉剛 孫繼先 逯登榮 王敏'
hdr_cells=table2.rows[1].cells
hdr_cells[0].text=u'開機時間:00:00-24:00'
hdr_cells[1].text=u'關機時間:00:00-00:00'
table3=doc.add_table(rows=7,cols=1,style='Table Grid')
v31=d1.n1
v32=d1.n2
v33=d1.n3
v34=d1.n4
v35=d1.n5
v36=d1.n6
hdr_cells=table3.rows[0].cells
hdr_cells[0].text=u'值班人員:'+v31+' '+v32+' '+v33+' '+v34+' '+v35+' '+v36
hdr_cells=table3.rows[1].cells
hdr_cells[0].text=u'天氣狀況:'
hdr_cells=table3.rows[2].cells
hdr_cells[0].text=u'運行環境狀況:正常'
hdr_cells=table3.rows[3].cells
hdr_cells[0].text=u'設備運行狀況:正常'
hdr_cells=table3.rows[4].cells
hdr_cells[0].text=u'觀測課題名稱:銀河畫卷'
hdr_cells=table3.rows[5].cells
hdr_cells[0].text=u'課題負責人:楊戟 徐燁'
hdr_cells=table3.rows[6].cells
hdr_cells[0].text=u'有效觀測時間:'
table4=doc.add_table(rows=5,cols=6,style='Table Grid')
v41=d1.x33
v42=d1.x55
v43=d1.x66
v41=str(v41)
v42=str(v42)
v43=str(v43)
hdr_cells=table4.rows[0].cells #huo qu line 0 suo you dan yuan ge
hdr_cells[0].text='Source'
hdr_cells[1].text='R.A.'
hdr_cells[2].text='Dec.'
hdr_cells[3].text='Source'
hdr_cells[4].text='R.A.'
hdr_cells[5].text='Dec.'
hdr_cells=table4.rows[1].cells
hdr_cells[0].text=v41
hdr_cells[1].text=v42
hdr_cells[2].text=v43
table5=doc.add_table(rows=1,cols=1,style='Table Grid')
hdr_cells=table5.rows[0].cells
hdr_cells[0].text=u'獲取資料質量評估:'
table6=doc.add_table(rows=2,cols=3,style='Table Grid')
hdr_cells=table6.rows[0].cells
hdr_cells[0].text='R.M.S'
hdr_cells[1].text='TA'
hdr_cells[2].text='VEL'
hdr_cells=table6.rows[1].cells
hdr_cells[0].text=u'差'
hdr_cells[1].text=u'優'
hdr_cells[2].text=u'優'
table7=doc.add_table(rows=5,cols=1,style='Table Grid')
v71=d1.Tyh
v711=v71[0]
v712=v71[1]
v72=d1.tk
v72=v72[0]
v73=d1.kk
v73=v73[0]
v74=d1.tt
v74=v74[0]
v75=d1.strtime
v76=d1.Trr
hdr_cells=table7.rows[0].cells
hdr_cells[0].text=u'故障描述:'
hdr_cells=table7.rows[1].cells
hdr_cells[0].text=u'故障發生時間:'
hdr_cells=table7.rows[2].cells
hdr_cells[0].text=u'故障排除措施:'
hdr_cells=table7.rows[3].cells
hdr_cells[0].text=u'維修人員:'
hdr_cells=table7.rows[4].cells
for time in v76:
hdr_cells[0].text=u'開展的主要工作:'+\
'\n(1)'+v711+','+v712+u',銀河畫卷計劃;'+\
'\n(2)'+v72+u',進行課題觀測,'+u'課題編號爲:'+v73+';'+\
'\n(3)'+v74+u',北極區觀測;'+\
'\n(4)'+v75+u',BZY測試;'+\
'\n(5)'+time+u',天氣差,暫停觀測;'
doc.save('2.docx')