インテリジェントに整列させたいデータの列があります ( gspreadのおかげで Google ドキュメントから簡単にインポートできます)。エントリを辞書に取り込みます。入力には、電子メール、Twitter ハンドル、またはブログ URL を含めることができます。例えば:
mike.j@gmail.com
@mikej45
j.mike@world.eu
_http://tumblr.com/mikej45
現在、「ダム」バージョンは次のとおりです。
def NomineeCount(spreadsheet):
worksheet = spreadsheet.sheet1
nominees = worksheet.col_values(6) # F = 6
unique_nominees = {}
for c in nominees:
pattern = re.compile(r'\s+')
c = re.sub(pattern, '', c)
if unique_nominees.has_key(c) == True: # If we already have the name
unique_nominees[c] += 1
else:
unique_nominees[c] = 1
# Print out the alphabetical list of nominees with leading vote count
for w in sorted(unique_nominees.keys()):
print string.rjust(str(unique_nominees[w]), 2)+ " " + w
return nominees
if プロセス中にいくつかのスマートを追加する効率的な (-ish) 方法は何ですか?