Skip to content

Instantly share code, notes, and snippets.

View JoelRJ's full-sized avatar

Joel Johnson JoelRJ

  • Payson, Utah
  • 02:36 (UTC -06:00)
View GitHub Profile
@JoelRJ
JoelRJ / Slackbot.ipynb
Created December 14, 2023 20:48
This is a Jupyter Notebook.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JoelRJ
JoelRJ / Invoice & Contracts PDF Merger.py
Last active January 2, 2024 12:44
This is the $100 PDF Merger my client paid me for. It merges each invoice with as many contracts as it can find with the invoice id in it. I added comments to make it easy to adjust to your own needs.
import re
import PyPDF2
import os
import datetime
def get_invoice_id(invoice_path):
'''Finds the invoice ID in the first page of the invoice'''
pdf_reader = PyPDF2.PdfReader(invoice_path)
page_text = pdf_reader.pages[0].extract_text()
@JoelRJ
JoelRJ / grab_username.py
Created October 24, 2023 13:38
Regex to grab username from Email for Python in Excel
import re
email = 'test@example.com'
pattern = r'^[^@]+'
match = re.search(pattern, email)
if match:
username = match.group()
else:
import PyPDF2
reader1 = PyPDF2.PdfReader('Front Sides.pdf')
reader2 = PyPDF2.PdfReader('Back Sides.pdf')
writer = PyPDF2.PdfWriter()
total_pages1 = len(reader1.pages)
total_pages2 = len(reader2.pages)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import csv
import sys
import os
# Get file_name from user, add .csv if not included
if len(sys.argv) == 1:
file_name = input('Enter the name of the file you would like to divide up: ')
else:
file_name = sys.argv[1]
from pathlib import Path
# pip install PySimpleGUI
import PySimpleGUI as sg
# pip install pandas
import pandas as pd
# Open Excel file
current_dir = Path(__file__).parent if '__file__' in locals() else Path.cwd()
EXCEL_FILE = current_dir / 'Data_Entry.xlsx'
# pip3 install pandas
import pandas as pd
import os
# Read in data from all .csv files in folder
DIRECTORY = input('What is the name of the folder with the Excel files?')
# Iterate over all files in that folder
for filename in os.listdir(DIRECTORY):
f = os.path.join(DIRECTORY, filename)
import os
folder = "data folder"
for count, filename in enumerate(os.listdir('./data folder')):
new_filename = f"{folder}/Datafile {count} 5-10-22.txt"
source =f"{folder}/{filename}"
os.rename(source, new_filename)
# pip3 install keyboard
from keyboard import press, is_pressed
import time
# Change 'refresh_seconds' for how often right arrow is pressed
refresh_seconds= 2
# Change 'duration_minutes' for how long you would like program to run
duration_minutes = 0.25
count = 0