Two years ago today I started studying the Python programming language. I had heard how Python is supposed to be an easy language to learn, and I thought it might be useful. Here is a sampling of the ways that I have used Python:
- Checking for errors on my website
- Scraping IRS and other web pages
- Automating tasks
- Searching my client files
- Searching my database of tax authorities
- Summarizing information to study/review
Checking for Website Errors
My website has over 1,200 charts on it. Each chart is a separate PDF file. I have two web pages (Alpha and Topic) that link to all of the charts. As we add new charts to the website, inevitably small typos are made, and the descriptions in the links on Alpha and Topic differ. I have used Python to compare the descriptions between the two web pages to find discrepancies. I now have a Python script that runs periodically to confirm the descriptions for all of the links on both pages are identical.
All 1,200+ PDF files include a title and author. We always try to add the title and author to the file before it is uploaded. However, sometimes we forget to do this. I used Python to confirm that the title and author are included and accurate for all 1,200+ PDF files.
As recommended by Google, we have a sitemap that includes links to all of the pages on our website (including links to the 1,200+ charts). Sometimes when we upload new charts to the website we forget to update the sitemap. I now have a Python script that runs periodically to confirm the sitemap is consistent with the published charts.
Scraping Web Pages
Every once in a while the IRS Office of Chief Counsel will publish legal opinions on certain matters. I like to be notified when the IRS publishes these opinions. I have a Python script that periodically checks (i.e., “scrapes”) the IRS web page with the opinions to see if any new opinions have been published. If there are new opinions, Python sends me a notification email.
I have similar scripts for IRS practice units, and various other websites.
Each month I send out an email to the same group of people. The email needs to have multiple files attached, but the text in the email remains roughly the same. I have a Python script that creates the email, inputs the email addresses, inserts the subject and the body, and attaches the files. All I have to do is review the email and click send.
I sometimes need to add passwords to PDF files. I have a Python script that automates this process.
Searching Client Files
I keep my client files in binders with numbered tabs. An Excel file contains the index. Whenever I need to open a client file, I open Excel and search for the name of the client to find the tab number for that client. It feels like it takes a long time to open Excel. I now have a Python script that is run from the command line and searches the index. This search is much faster.
Searching Database of Tax Authorities
Whenever I come across a tax case or an IRS ruling that I find interesting, I add it to my database. My database is an Excel file that includes: (1) a citation to the case or ruling, (2) my own notes indicating what the case or ruling was about (including code sections and keywords that I anticipate I might search for in the future), and (3) related cases or rulings.
Over the decades, my database has grown to over 1,600 cases, nearly 1,500 rulings and notices, and over 500 private letter rulings. Whenever I want to find cases or rulings that deal with a particular topic, I open the Excel file and search for the topic.
I have created a Python script that searches the database and returns all of the hits. Not only is the search very fast, it produces results that are more concise and it allows me to tailor the search in multiple different ways.
Summarizing Information For Study/Review
Periodically I like to review the items in my database. I have a Python script that extracts selected items from the database and exports them as a text file to DropBox. From my iPad, I import the text file into a text-to-speech program. I can then simultaneously read and listen to the text out loud.
[100% human generated text.]