Skip to content

Instantly share code, notes, and snippets.

@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()
@AO8
AO8 / syllable_counter.py
Last active January 10, 2019 18:26
Use Python 3, NLTK, and the Carnegie Mellon University Pronouncing Dictionary to count the syllables in an English word or phrase.
# NLTK is a suite of libraries for working with human language data: http://www.nltk.org
# NLTK allows us to access the Carnegie Mellon University Prounouncing Dictionary (cmudict)
# cmudict is a corpus that contains almost 125,000 words mapped to their pronunciations.
# This tiny app was inspired by Lee Vaughn's Impractical Python Projects
import sys
from string import punctuation
from nltk.corpus import cmudict
# load corpus and build dictionary
@AO8
AO8 / journal.py
Last active January 11, 2019 22:27
More File I/O practice: a simple MyJournal app with Python 3, taken from Michael Kennedy's Python Jumpstart by Building 10 Apps course.
import os
def load(name):
"""
This method creates and loads a new journal.
:param name: This base name of the journal to load.
:return: A new journal data structure populated with file data.
"""
data = []
filename = get_full_pathname(name)
@AO8
AO8 / deque.py
Last active December 18, 2018 17:19
Deque practice with Python 3.
# Exercise completed as part of Erin Allard's Lynda.com course,
# 'Python Data Structures: Stacks, Queues, and Deques'
class Deque:
"""An ADT that resembles both a Stack (LIFO) and a Queue (FIFO).
Items in a deque can be added to and removed from both the back
and front.
Don't reinvent the wheel. More simply, from collections import deque
https://docs.python.org/3/library/collections.html#collections.deque