#!/usr/bin/env?python
#?coding:?utf-8
#
import?csv
collector?=?{}
with?open(r"/home/tim/downloads/test.csv")?as?handle:
for?data?in?csv.DictReader(handle):
collector.setdefault(data["區域"],?[]).append(data)
for?area,?datas?in?collector.items():
print?area,?len(datas),?\
len(filter(lambda?x:?x["web使用天數"]?>?'0',?datas)),?\ len(filter(lambda?x:?x["client使用天數"]?>?'0',?datas))tim@crunchbang:~$?python?baidu.py
雁塔分部?13?9?3
蓮湖分部?9?3?2
新城分部?10?5?5
上面的代碼未處理寫excel的功能