Skip to content

Instantly share code, notes, and snippets.

@sreejithpro
sreejithpro / alpPrint.py
Last active November 20, 2023 09:48
An experiment using PyAutoGUI to automate windows actions. This code opens an ALP files, delete results, analyze results, click all results and take a PDF print out
import os
import time
import pyautogui
def count_files(folder_path):
return sum(file.endswith('.alw') and not file.startswith('~$') for file in os.listdir(folder_path))
# Path to the file you want to open
@sreejithpro
sreejithpro / summarise.py
Last active February 2, 2024 08:41
Summarise information from a set of excel files into a summary sheet
import os
import xlwings as xw
# Setup the application
app = xw.App(visible=False)
app.display_alerts = False
# Create a new workbook
new_wb = app.books.add()
@sreejithpro
sreejithpro / insertFormula.py
Created November 20, 2023 09:28
Open excel sheets, insert formulas into the worksheets, save and close.
import os
import xlwings as xw
# Define the path to the folder containing the Excel files
folder_path = r"source folder" # <-- MODIFY THIS PATH
# Define the formulas to be inserted
formula1 = "=C14" # <-- Your Formula1
# formula2 = "=MAX(G16,H16)" # <-- Your Formula2
# formula3 = '=IF(I4="Your Criteria",J13,J14)' # <-- Your Formula3
@sreejithpro
sreejithpro / copyWorkbook.py
Last active November 20, 2023 09:24
Copy the specified sheets in a source file to target files
import os
import xlwings as xw
# Paths
source_workbook_path = r"source workbook path" # Change to your source workbook path
target_folder_path = r'targer folder' # Change to the folder containing your target workbooks
# Names of the worksheets you want to copy
sheets_to_copy = ['Sheet1', 'Sheet2'] # Change to your sheet names
@sreejithpro
sreejithpro / bgsmaps_extractor.py
Last active April 19, 2023 13:48
python script to download a snip of bedrock and superficial geology of a location from BGS maps. It also copies the geology to an excel sheet.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import time
import pandas as pd
@sreejithpro
sreejithpro / delete_emails.gs
Last active March 15, 2023 16:00
Search for read email with sender and subject from a google doc and delete them
function deleteEmails() {
var sheet = SpreadsheetApp.openById('SHEET ID').getSheetByName('Sheet1');
var data = sheet.getDataRange().getValues();
for (var i = 1; i < data.length; i++) {
var sender = data[i][0];
var subject = data[i][1];
var threads = GmailApp.search('is:read from:' + sender + ' subject:' + subject);
Logger.log('Deleted' + i + ' emails')
@sreejithpro
sreejithpro / downloadUnreadEmails.gs
Last active March 15, 2023 15:49
Find unread emails in gmail and copy sender and subject in a google doc
function downloadUnreadEmails() {
var sheet = SpreadsheetApp.create('Unread Emails');
sheet.appendRow(['Sender', 'Subject']);
var threads = GmailApp.search('is:unread');
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {