Skip to content

Instantly share code, notes, and snippets.

View israel-dryer's full-sized avatar

Israel Dryer israel-dryer

View GitHub Profile
@israel-dryer
israel-dryer / docx_term_search.py
Created July 21, 2020 18:32
Quick and direct search for term inside docx file
"""
A quick and dirty search within the contents of a docx file
Author: Israel Dryer
Modified: 2020-07-21
"""
from zipfile import ZipFile
# file path
doc_path = 'senior_paper.docx'
@israel-dryer
israel-dryer / simple_clock_psg.py
Created July 31, 2020 18:01
Simple clock update for PySimpleGUI
"""
A simple clock demonstration in PySimpleGUI
>> YouTube Comments Response <<
"""
import PySimpleGUI as sg
from datetime import datetime
layout = [[sg.Text(text=datetime.now().strftime('%I:%M:%S'), key='-CLOCK-')]]
@israel-dryer
israel-dryer / wordwrap_example.py
Last active September 5, 2020 08:45
How to disable word-wrap in PySimpleGUI output
import PySimpleGUI as sg
# create output element
output = sg.Output(size=(50, 15))
# button to initiate text printing
button = sg.Button('Print long text', key='-BTN-')
# set the layout
layout = [[output], [button]]
@israel-dryer
israel-dryer / gist:bc92cd8bd960492f2cbce617db68cf5e
Created September 7, 2020 15:10
Find Excel table range with win32com

Find Excel Range in Workbook

import win32com.client as client
import pathlib

Initialize the application

@israel-dryer
israel-dryer / py_list_to_html_list.py
Created September 16, 2020 14:50
Insert python list into html formatted email template
"""
Create a html formatted list from a python list
"""
# email template with curly braces to insert list
email_template = '''
<p>Hello, here are the items that you ordered:<br>
{}
</p>
'''
@israel-dryer
israel-dryer / message_finder.py
Created September 19, 2020 02:08
Identify undeliverable messages in Outlook
import re
import win32com.client as client
# pattern for identifying email addresses
pattern = re.compile(r'mailto:(\w+\.\w+@company.com)')
outlook = client.Dispatch('Outlook.Application')
namespace = outlook.GetNameSpace('MAPI')
inbox = namespace.Folders['Inbox']
@israel-dryer
israel-dryer / add_dl_members.py
Created September 22, 2020 01:35
Add members to an Outlook distribution
"""
Add members to an existing user distribution list in Python
https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.recipients
https://docs.microsoft.com/en-us/office/vba/api/outlook.distlistitem.addmembers
https://docs.microsoft.com/en-us/office/vba/api/outlook.oldefaultfolders
"""
import win32com.client as client
# start an instance of outlook
@israel-dryer
israel-dryer / wiki_homepage.txt
Created September 30, 2020 22:22
Wiki homepage example
Welcome to a series of tutorials on how to get the most out of Microsoft Outlook using python!
<table>
<tr>
<td>
<ul><b>
<li><a href="https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki">Home</a></li>
<li><a href="https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki/Getting-started">Getting started</a></li>
<li><a href="https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki/Plain-text-email">Plain text email</a></li>
<li><a href="https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki/HTML-formatted-email">HMTL formatted email</a></li>
@israel-dryer
israel-dryer / gist:350fe21e49bc9445f5b6827a668f247e
Created November 20, 2020 14:17
Example - Saving data to CSV
import csv
import requests
from bs4 import BeautifulSoup
stock = ['AMZN','AXP','AAPL','AXTA','BAC']
# create csv writer
f = open("data_file.csv", "w", newline="", encoding="utf-8")
writer = csv.writer(f)
# add header to csv file
@israel-dryer
israel-dryer / yt_question_find_and_break.py
Created December 28, 2020 17:50
example of find a word in a subject line then performing action; then stopping.
search_term = "product"
for message in inbox.Items:
if search_term in message.Subject:
do_something()
break # this will break out of the loop once the item is found