Skip to content

Instantly share code, notes, and snippets.

@AO8
AO8 / sentiment_analyzer.py
Created October 30, 2019 20:05
This tiny Python app, powered by TextBlob, quickly measures the polarity and subjectiviy of a piece of text.
# This Python program quickly measures the polarity and subjectivity of a piece of text.
from time import sleep
from textblob import TextBlob
def print_header():
print("*"*67)
print("PYTHON SENTIMENT TESTER (Powered by TextBlob)")
print()
print("POLARITY:")
@AO8
AO8 / secret_santa_pairing_program.py
Last active October 30, 2019 20:52
Create random Secret Santa gift-giving assignments at the click of a button with Python 3.
# Step 1: Set up a Google form that collects First Name, Last Name, and Email Address from participants
# Step 2: Once all participants have completed the form, export it as a CSV file and store it in the same directory as this program
# Step 3: Run the program to create random Secret Santa gift-giving assignments so that each participant is paired with a different participant without duplication or anyone being left out
import csv
import datetime
import random
def main():
participants = get_participants_from_csv("test_file.csv")
@AO8
AO8 / grade_multi_plot.py
Last active March 29, 2019 20:08
Plot multiple subplots within a single figure to visualize the shape of grade distribution in various IT courses with Python 3 and Matplotlib.
# Corresponding CSV files exported from local SQL Engine.
import csv
from collections import Counter
import matplotlib.pyplot as plt
grades_102 = []
grades_201 = []
grades_206 = []
grades_207 = []
@AO8
AO8 / month_analyzer_bar_plot.py
Created March 26, 2019 21:28
Fine-tuning matplotlib bar plot of Calendly appointment data. Ongoing Python 3 project.
import csv
import calendar
from collections import Counter
import matplotlib.pyplot as plt
# set up empty Counter objectS
months_counter = Counter()
# open and read CSV
with open("dashboard-export.csv") as f:
@AO8
AO8 / txt_word_counter.py
Last active March 1, 2019 19:25
Another take on a simple word counter app with Python with some regex practice for good measure. Users enter a TXT file, specific a word to search, and the app returns the number of time that word occurs in the file
import re
from collections import Counter
def main():
print_header()
user_file = input("Enter the absolute path for your TXT file:\n\n")
print()
wc = get_word_counter(user_file)
print()
get_count_of_word(wc)
@AO8
AO8 / amazon_purchase_analyzer.py
Last active February 14, 2019 00:17
A simple Python 3 app to explore your Amazon.com purchase history CSV data.
import csv
import sys
from collections import Counter, defaultdict
from datetime import datetime as dt
from decimal import Decimal
from time import sleep
# First import your purchases data from Amazon.com and store CSV
# file in the same directory as this program.
# Column names in CSV file for reference
@AO8
AO8 / crime_address_analyzer.py
Last active February 8, 2019 18:56
A quick program to analyze crime by reported address with Python 3 using local city crime data.
# Auburn, WA Police Data CSV available at: https://data.auburnwa.gov/
import csv
import sys
from collections import Counter
# CSV headers for reference
# [0] CASENUMBER
# [1] OFFENSE
# [2] OFFENSETYPE
@AO8
AO8 / crime_analyzer.py
Last active February 7, 2019 17:31
Auburn, WA crime analyzer with Python 3. This small project provided an exercise in working with CSV files and open data from the City of Auburn.
# Auburn, WA Police Data CSV available at: https://data.auburnwa.gov/
import csv
import sys
from collections import Counter
from datetime import datetime as dt
# Rows in CSV file for reference:
# [0] CASENUMBER
# [1] OFFENSE
@AO8
AO8 / get_dose_of_marcus.py
Last active January 17, 2019 23:17
Get a daily dose of Stoic thought from one of my favorite philosophers, Marcus Aurelius. If you like the quote you receive, you can email it to a friend. This small project is based in Python 3.6 and offered practice with basic File I/O and several Standard Library modules including MIMETEXT, SMTPLIB, SSL, and TEXTWRAP. Also getting more acquain…
import random
import smtplib
import ssl
import sys
import textwrap
from email.mime.text import MIMEText
from datetime import datetime
def main():
print_header()
@AO8
AO8 / count_syllables.py
Created January 14, 2019 16:36
Generate random haikus with Python, NLTK, and Markhov Chain Analysis. Includes the ability to email randomly generated haikus to yourself or a friend using Gmail and Python's built-in SMTP and Email modules. Adapted from chapters 8 and 9 of Lee Vaughan's Impractical Python Projects.
import sys
from string import punctuation
import json
from nltk.corpus import cmudict
# load dict of words in corpus but not in cmudict
with open("missing_words.json") as f:
missing_words = json.load(f)
cmudict = cmudict.dict()