Created
August 18, 2011 16:12
-
-
Save miio/1154411 to your computer and use it in GitHub Desktop.
抽選プログラム
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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