Skip to content

Instantly share code, notes, and snippets.

@skwashd
Last active July 24, 2025 03:55
Show Gist options
  • Save skwashd/a8c92ac7a03c142d22da551fdf3f4185 to your computer and use it in GitHub Desktop.
Save skwashd/a8c92ac7a03c142d22da551fdf3f4185 to your computer and use it in GitHub Desktop.
Random Name Picker

Random Name Picker

At the AWS Canberra User Group meeting on 23 July 2025, our panel discussed Responsible AI.

After the panel I used vibe code mode in Kiro to create a script for picking random attendees to win AWS vouchers. I wanted to show off Kiro in a fun way.

The prompt I used was deliberately short. Here it is:

Create a Python script to pick people at random from a CSV file. The names are contained in the first column of the file. Draw one name, then prompt if another name is needed. Ensure a name can only be drawn once. Do not use external libraries.

The code worked and drew our 5 winners.

#!/usr/bin/env python3
"""
Random Name Picker from CSV
Picks names randomly from the first column of a CSV file.
Each name can only be drawn once.
"""
import csv
import random
import sys
import os
def load_names_from_csv(filename):
"""Load names from the first column of a CSV file."""
names = []
try:
with open(filename, 'r', newline='', encoding='utf-8') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
if row and row[0].strip(): # Skip empty rows and empty first columns
names.append(row[0].strip())
return names
except FileNotFoundError:
print(f"Error: File '{filename}' not found.")
return None
except Exception as e:
print(f"Error reading file: {e}")
return None
def main():
# Get CSV filename from user
if len(sys.argv) > 1:
filename = sys.argv[1]
else:
filename = input("Enter the CSV filename: ").strip()
if not filename:
print("No filename provided.")
return
# Load names from CSV
names = load_names_from_csv(filename)
if names is None:
return
if not names:
print("No names found in the CSV file.")
return
print(f"Loaded {len(names)} names from '{filename}'")
print("-" * 40)
# Create a copy of names list for drawing
available_names = names.copy()
drawn_count = 0
while available_names:
# Draw a random name
chosen_name = random.choice(available_names)
available_names.remove(chosen_name)
drawn_count += 1
print(f"Name #{drawn_count}: {chosen_name}")
print(f"Remaining names: {len(available_names)}")
if not available_names:
print("\nAll names have been drawn!")
break
# Ask if user wants another name
while True:
response = input("\nDraw another name? (y/n): ").strip().lower()
if response in ['y', 'yes']:
break
elif response in ['n', 'no']:
print("Thanks for using the random name picker!")
return
else:
print("Please enter 'y' for yes or 'n' for no.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment