def getIHGU_data_csv(request):
startTime=time.time()
json_str={}
#获取参数
if request.method == "GET":
filePath='/data/IHGUData/souceData/'
dirs = os.listdir(filePath)
for dir in dirs:
fileName=filePath+dir
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=%s' % (dir)
writer = csv.writer(response)
writer.writerow(['id', 'reportTime','snNum','PONshou','PONjie','upMaxFlow','upAvgFlow','downMaxFlow','downAvgFlow'])
for line in open(fileName):
datalist=line.replace('\n', '').split(",")
writer.writerow(datalist)
os.system("mv %s /data/IHGUData/historyData/" % (filePath+dir));
return response