Skip to content

Instantly share code, notes, and snippets.

@IvansNab
IvansNab / spreadsheetCellInverter.py
Created March 14, 2021 17:35
spreadsheet cell inverter automate the boring stuff
'''
Spreadsheet Cell Inverter
Write a program to invert the row and column of the cells in the spread-
sheet. For example, the value at row 5, column 3 will be at row 3, column 5
(and vice versa). This should be done for all cells in the spreadsheet.
ITEM SOLD
Apples 73
Cherries 85
@IvansNab
IvansNab / blankRowInserter.py
Last active March 16, 2021 14:39
blank row inserter automate the boring stuff
'''
Blank Row Inserter
Create a program blankRowInserter.py that takes two integers and a filename
string as command line arguments. Let’s call the first integer N and the sec-
ond integer M. Starting at row N, the program should insert M blank rows
into the spreadsheet. For example, when the program is run like this:
python blankRowInserter.py 3 2 myProduce.xlsx
A B C
1 asdf asdf asdf
@IvansNab
IvansNab / multiplicationTable.py
Created March 13, 2021 16:07
multiplication table maker automate the boring stuff
'''
Multiplication Table Maker
Create a program multiplicationTable.py that takes a number N from the
command line and creates an N×N multiplication table in an Excel spreadsheet.
For example, when the program is run like this:
py multiplicationTable.py 3
. . . it should create a spreadsheet:
A B C D
@IvansNab
IvansNab / 2048.py
Last active March 10, 2021 14:54
2048 automate the boring stuff
'''
2048
2048 is a simple game where you combine tiles by sliding them up, down,
left, or right with the arrow keys. You can actually get a fairly high score
by repeatedly sliding in an up, right, down, and left pattern over and over
again. Write a program that will open the game at https://gabrielecirulli
.github.io/2048/ and keep sending up, right, down, and left keystrokes to
automatically play the game.
'''
@IvansNab
IvansNab / fillingInTheGaps.py
Created March 4, 2021 10:37
filling in the gaps automate the boring stuff
'''
Filling in the Gaps
Write a program that finds all files with a given prefix, such as spam001.txt,
spam002.txt, and so on, in a single folder and locates any gaps in the num-
bering (such as if there is a spam001.txt and spam003.txt but no spam002.txt).
Have the program rename all the later files to close this gap.
As an added challenge, write another program that can insert gaps
into numbered files so that a new file can be added.
'''
import pyinputplus as pyip
@IvansNab
IvansNab / deletingUnneededFiles.py
Last active March 3, 2021 11:36
deleting unneeded files automate the boring stuff
'''
Deleting Unneeded Files
It’s not uncommon for a few unneeded but humongous files or folders to
take up the bulk of the space on your hard drive. If you’re trying to free up
room on your computer, you’ll get the most bang for your buck by deleting
the most massive of the unwanted files. But first you have to find them.
Write a program that walks through a folder tree and searches for excep-
tionally large files or folders—say, ones that have a file size of more than
100MB. (Remember that to get a file’s size, you can use os.path.getsize() from
the os module.) Print these files with their absolute path to the screen.
@IvansNab
IvansNab / selectiveCopy.py
Created March 2, 2021 11:03
selective copy automate the boring stuff
'''
Selective Copy
Write a program that walks through a folder tree and searches for files with
a certain file extension (such as .pdf or .jpg). Copy these files from whatever
location they are in to a new folder.
'''
import shutil, os
def pathInputAndCheck():
while True:
@IvansNab
IvansNab / regexSearch.py
Created February 28, 2021 14:46
regex search automate the boring stuff
'''
Write a program that opens all .txt files in a folder and searches for any
line that matches a user-supplied regular expression. The results should
be printed to the screen.
'''
import re
from pathlib import Path
import pyinputplus as pyip
@IvansNab
IvansNab / madLibs.py
Last active February 27, 2021 19:16
mad libs automate the boring stuff
'''
Create a Mad Libs program that reads in text files and lets the user add
their own text anywhere the word ADJECTIVE, NOUN, ADVERB, or VERB
appears in the text file. For example, a text file may look like this:
The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was
unaffected by these events.
The program would find these occurrences and prompt the user to
replace them.
Enter an adjective:
silly
@IvansNab
IvansNab / mcb.pyw
Last active February 26, 2021 10:43
Extending the Multi-Clipboard automate the boring stuff
'''
Extending the Multi-Clipboard
Extend the multi-clipboard program in this chapter so that it has a delete
<keyword> command line argument that will delete a keyword from the shelf.
Then add a delete command line argument that will delete all keywords.
'''
#! python3
# mcb.pyw - Saves and loads pieces of text to the clipboard.
# Usage: py.exe mcb.pyw save <keyword> - Saves clipboard to keyword.
# py.exe mcb.pyw <keyword> - Loads keyword to clipboard.