Skip to content

Commit 4174ebb

Browse files
committed
refactored with argparse
1 parent 6cd3f59 commit 4174ebb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

raffle.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import csv
22
import random
3-
import sys
3+
import argparse
44
from random import shuffle
5-
totalWinners = 48
5+
parser = argparse.ArgumentParser()
6+
parser.add_argument("csv",help = "the location of the csv input")
7+
args = parser.parse_args()
68
winlist = []
7-
with open(sys.argv[1]) as csvfile:
9+
csvrow = open(args.csv)
10+
totalWinners = sum(1 for row in csvrow)
11+
with open(args.csv) as csvfile:
812
reader = csv.DictReader(csvfile)
913
for row in reader:
1014
username = row['What username do you go by online?']

0 commit comments

Comments
 (0)