Skip to content

Instantly share code, notes, and snippets.

@miio
Created August 18, 2011 16:12
Show Gist options
  • Save miio/1154411 to your computer and use it in GitHub Desktop.
Save miio/1154411 to your computer and use it in GitHub Desktop.
抽選プログラム
#!/usr/bin/python
#coding: UTF-8
import csv
import random
filename = "entry.csv"
csvfile = open(filename)
list = []
#Parse CSV to list.
#Notice :
# Cancel user group is after 2 null column.
# Skip first column because it's description.
cancel_flg = 0
skipped_first_flg = False
for target in csv.reader(csvfile):
if cancel_flg < 2:
if not skipped_first_flg:
skipped_first_flg = True
elif len(target) <= 0:
cancel_flg += 1
else:
list.append(target[0])
print random.choice(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment