# _*_ coding:utf-8 _*_
#use:xuniwaichang yong
#time:2016/11/4
#writer:zhangyonghang
#win+python2.7.x
#使用的库
import csv,os,sys
import xlwt,xlrd
from xlrd import open_workbook
from xlutils.copy import copy
#为数组获得空间
Azimuth=[None]*100000
Elevation=[None]*100000
qiangdu=[None]*100000
#经度
def hengzhou():
with open(r'D:\ceshi\d.csv','rb') as csvfile1:
reader = csv.reader(csvfile1)
k=-1
#rows= [row for row in reader]
for a in range (1,30000):
column = [row[3] for row in reader]
for i,rows in enumerate(column):
k=k+1
#print k
#print i
#print rows
if i == k & i>0:
#print 11
row=rows
#print row
row = row.replace('\r','').replace('\n','').replace('\t','')
Azimuth[i]=int(row)
'''filename = xlwt.Workbook ()
# Azimuth[a] = Azimuth[a].replace('\r','').replace('\n','').replace('\t','')
#print Azimuth[a]
sheet = filename.add_sheet('name')
rb = open_workbook('test1.xls')
wb = copy(rb)
sheet = wb.get_sheet(0)
# sheet.write((19-(int((Azimuth[a])/5))),2,Azimuth[a])
#print (19-(int((Azimuth[a])/5)))
sheet.write(Azimuth[i]-1,2,Azimuth[i])
wb.save('test1.xls')'''
def zongzhou():
with open(r'D:\ceshi\d.csv','rb') as csvfile1:
reader = csv.reader(csvfile1)
k=-1
#rows= [row for row in reader]
for a in range (1,30000):
column = [row[2] for row in reader]
for i,rows in enumerate(column):
k=k+1
#print k
#print i
#print rows
if i == k & i>0:
#print 11
row=rows
#print row
row = row.replace('\r','').replace('\n','').replace('\t','')
Elevation[i]=int(row)
'''filename = xlwt.Workbook ()
# Azimuth[a] = Azimuth[a].replace('\r','').replace('\n','').replace('\t','')
#print Azimuth[a]
sheet = filename.add_sheet('name')
rb = open_workbook('test1.xls')
wb = copy(rb)
sheet = wb.get_sheet(0)
# sheet.write((19-(int((Azimuth[a])/5))),2,Azimuth[a])
#print (19-(int((Azimuth[a])5)))
sheet.write(Elevation[i]-1,Elevation[i]-2,427)
wb.save('test1.xls')'''
def cn0():csv.reader(csvfile1)
k=-1
#rows= [row
with open(r'D:\ceshi\d.csv','rb') as csvfile1:
reader = for row in reader]
for a in range (1,30000):
column = [row[1] for row in reader]
for i,rows in enumerate(column):
k=k+1
#print k
#print i
#print rows
if i == k & i>0:
#print 11
row=rows
#print row
row = row.replace('\r','').replace('\n','').replace('\t','')
qiangdu[i]=int(row)
# print qiangdu[i]
#print Azimuth[a]
#print 22
'''print i
filename = xlwt.Workbook ()
sheet = filename.add_sheet('name')
rb = open_workbook('test1.xls')
wb = copy(rb)
sheet = wb.get_sheet(0)
# sheet.write((19-(int((Azimuth[a])/5))),2,Azimuth[a])
#print (19-(int((Azimuth[a])5)))
sheet.write(qiangdu[i]-1,qiangdu[i]-2,27)
wb.save('test1.xls')'''
'''def putdata():
for a in range (1,21):
filename = xlwt.Workbook ()
sheet = filename.add_sheet('name')
rb = open_workbook('test1.xls')
wb = copy(rb)
sheet = wb.get_sheet(0)
# sheet.write((19-(int((Azimuth[a])/5))),2,Azimuth[a])
#print (19-(int((Azimuth[a])5)))
sheet.write((5,2,qiangdu[a]))
wb.save('test1.xls')‘’‘'''
if __name__=="__main__":
hengzhou()
zongzhou()
cn0()
#putdata()
c=1
for a in range (1,30000):
#print qiangdu[a],Azimuth[a],Elevation[a]
#计数用
#c=c+1
#print c
filename = xlwt.Workbook ()
#储存数据
sheet = filename.add_sheet('name')
rb = open_workbook('test1.xls')
wb = copy(rb)
sheet = wb.get_sheet(0)
# sheet.write((19-(int((Azimuth[a])/5))),2,Azimuth[a])
#print (19-(int((Azimuth[a])5)))
if Azimuth[a]>174:
sheet.write((18-(Elevation[a]/5)),((Azimuth[a])/5-35),qiangdu[a])
#sheet.write((19-(Elevation[a]/5)),((Azimuth[a])/5-35),qiangdu[a])
wb.save('test1.xls')
else:
sheet.write((18-(Elevation[a]/5)),((Azimuth[a])/5+37),qiangdu[a])
wb.save('test1.xls')