def LocationPerformanceCSV(request):
# Create the HttpResponse object with the appropriate CSV header.
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="locationPerformance.csv"'
startDate = getDateTimeFromGet(request,'startDate')
endDate = getDateTimeFromGet(request,'endDate')
results = getLocationPerformance(startDate,endDate)
writer = csv.writer(response)
# Note: These are not translated because the chart Javascript looks for these keys
writer.writerow(['Location','# Series','# Students','Avg. Students/Series'])
for location,data in results.items():
writer.writerow([
location, # The location name
data.get('series',0), # The num. of series taught there
data.get('registrations',0), # The num. of students taught there
float(data.get('registrations',0)) / data.get('series',1)
])
return response
评论列表
文章目录