stats.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:django-danceschool 作者: django-danceschool 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号