Cover of Automate the Boring Stuff with Python 2nd Edition by Al Sweigart, featuring a snake graphic on a bold background

Pages

593

Published

2019

Python ✨ New

Automate the Boring Stuff with Python, 2nd Edition

A practical guide to automating everyday tasks with Python — no prior experience required

Stop doing by hand what Python can do for you: learn to automate files, spreadsheets, PDFs, web scraping, and more with real working scripts.

Automate the Boring Stuff with Python teaches you to write programs that do in minutes what would take you hours to do manually. Al Sweigart walks you through Python fundamentals and then immediately applies them to practical automation tasks: manipulating files and folders, reading spreadsheets, scraping websites, filling out forms, and scheduling jobs. Every chapter builds a tool you can actually use — no toy examples, no academic exercises.

About this book

Most programming books teach you syntax. This one teaches you to get things done. Al Sweigart starts from the ground up — no prior programming experience assumed — and moves quickly to the automation tasks that make Python worth learning in the first place.

The second edition, published in 2019, covers Python 3 throughout and adds new chapters on input validation, Gmail and Google Sheets integration, and updates to every project so the code runs against current libraries. The 593-page book is structured in two halves: a focused crash course in Python fundamentals, followed by a project-driven tour of automation topics that most developers encounter in their day-to-day work.

Each chapter closes with a working, useful program. By the time you finish, you will have built tools that rename hundreds of files according to a naming scheme, pull data from websites without a browser open, send scheduled email reports, read and write Excel spreadsheets without Excel installed, and manipulate PDFs in bulk. These are not demonstrations — they are scripts you can adapt and deploy the same day.

The automation topics covered include:

  • Pattern matching with regular expressions to search and transform text
  • Reading and writing CSV, Excel, and Google Sheets data
  • Web scraping with Beautiful Soup and controlling a browser with Selenium
  • Working with PDFs, Word documents, and email attachments
  • Scheduling tasks, launching programs, and working with the file system
  • Manipulating images programmatically with Pillow
  • Debugging, logging, and writing tests so your scripts stay reliable

Sweigart writes the way a patient senior developer explains things: plainly, without jargon, always with a concrete reason for each technique. If you spend any part of your week on repetitive computer work — renaming files, copying data between spreadsheets, filling in web forms — this book will pay for itself the first time you run one of its scripts.

🎯 What you'll learn

  • Write Python scripts from scratch, even with zero prior programming experience
  • Automate file and folder operations including renaming, moving, archiving, and searching across directories
  • Scrape structured data from websites using Beautiful Soup and automate browser interactions with Selenium
  • Read, write, and manipulate Excel spreadsheets and Google Sheets without opening a GUI application
  • Parse and generate PDFs and Word documents in bulk
  • Send and filter email and SMS messages programmatically using Gmail and Twilio APIs
  • Schedule scripts to run automatically and integrate them with your operating system's task runner
  • Debug and test your automation scripts so they fail gracefully and stay maintainable

👤 Who is this book for?

  • Office workers and analysts who repeat the same manual tasks daily and want Python to handle them instead
  • Beginners with no programming background who want a practical first Python book, not a theoretical one
  • Intermediate Python developers who learned the basics elsewhere but never applied them to real automation projects
  • System administrators who need quick, readable scripts for file management, scheduling, and process automation
  • Students taking introductory Python courses who want a second resource focused entirely on applied projects

Table of contents

  1. 01

    Python Basics

    Install Python and write your first programs. Learn variables, data types, expressions, and how to run scripts from the command line.

  2. 02

    Flow Control

    Control what your programs do with if statements, loops, and logical operators. Build scripts that make real decisions based on input.

  3. 03

    Functions

    Organize code into reusable functions, understand scope, and learn how to structure scripts so they are readable and maintainable.

  4. 04

    Lists

    Store and manipulate sequences of data with lists. Work through practical examples involving sorting, searching, and iterating over collections.

  5. 05

    Dictionaries and Structuring Data

    Use dictionaries and tuples to represent structured records and build small data-processing programs that go beyond simple lists.

  6. 06

    Pattern Matching with Regular Expressions

    Write regular expressions to search, validate, and transform text. Apply them to real tasks like extracting phone numbers and email addresses from documents.

  7. 07

    Files, Paths, and the File System

    Read, write, and manage files and directories on your computer. Build scripts that automate folder organization and bulk file renaming.

  8. 08

    Web Scraping

    Fetch web pages with the Requests library and parse their content with Beautiful Soup. Automate form submission and site navigation with Selenium.

  9. 09

    Excel, CSV, and Google Sheets

    Read and write spreadsheet data without opening Excel or a browser. Automate data extraction, transformation, and reporting across multiple files.

  10. 10

    PDFs, Word Documents, and Email

    Extract text from PDFs, generate Word documents programmatically, and send automated emails with attachments using Python's standard libraries and Gmail integration.

Frequently asked questions

Do I need any programming experience to read this book?

No prior experience is required. The book opens with a Python crash course that covers everything you need before moving into automation projects. Many readers with no coding background have worked through it successfully.

Which version of Python does the book use?

The second edition uses Python 3 throughout. All code examples and project scripts are written for Python 3, and the book includes instructions for installing it on Windows, macOS, and Linux.

Is this book useful if I already know basic Python?

Yes. The first few chapters will be a quick review, but the bulk of the book covers applied automation topics — web scraping, spreadsheet manipulation, PDF handling, scheduling — that most introductory courses never touch.

Are the code examples available to download?

Al Sweigart makes the book's source code available on the companion website listed in the book itself. No Starch Press also provides access through its website. Check the edition's front matter for the current URL.

Does the book cover web development or data science?

Neither. This book is specifically about automating desktop and administrative tasks: files, documents, web scraping, email, and scheduling. It is not a web framework tutorial or a data analysis guide.

Is the content still current given it was published in 2019?

The core automation techniques and Python 3 syntax remain accurate. A small number of third-party library APIs may have changed since publication, but the underlying patterns and the majority of code examples still run without modification.

You might also like

📬 Weekly Newsletter

Stay ahead of the curve

Get the best programming tutorials, data analytics tips, and tool reviews delivered to your inbox every week.

No spam. Unsubscribe anytime.