Automation with Python


Course Description

This course teaches Python 3 from the ground up and uses this to automate a variety of tasks. This includes document manipulation, web scraping, sending emails and data processing.

Duration: 3 days


Prerequisites

No specific pre-requisites. Previous programming experience an advantage.

Python basics

The Python environment
Variables
Keywords
Built in functions
Variable types

Flow Control

if and elif
Conditional expressions
Relational operators
Boolean operators
while loops
Alternate ways to exit a loop

Functions

Defining a function
Function parameters
Global variables
Variable scope
Returning values

Lists and Tuples

About sequences
Lists
Tuples
Indexing and slicing
Iterating through a sequence
Functions for all sequences
Using enumerate
Operators and keywords for sequences
The xrange() function
Nested sequences
List comprehensions
Generator expressions

Working with files

Text file I/O Opening a text file The with block Reading a text file Writing to a text file "Binary" (raw, or non-delimited) data

Exception handling

Exceptions
Handling exceptions with try
Handling multiple exceptions
Handling generic exceptions
Ignoring exceptions
Using else
Cleaning up with finally
re-raising exceptions
Raising a new exception
The standard exception hierarchy

Dictionaries and sets

About dictionaries
When to use dictionaries
Creating dictionaries
Getting dictionary values
Iterating through a dictionary
Reading file data into a dictionary
Counting with dictionaries
About sets
Creating sets
Working with sets

Classes

Defining classes
Instance objects
Instance attributes
Methods
__init__
Properties
Class data
Inheritance
Multiple Inheritance
Base classes
Special methods
Pseudo-private variables
Static methods

OS Commands

shutil Module and File Copies Deletion Walking the tree Playing with zip files Extracting from zips Creating zip files The os module Scheduling tasks Environment variables Launching external processes Paths, directories, and filenames Walking directory trees Dates and times

Pattern Matching with Regular Expressions

Creating regex Objects Multiple Matching Groups with | zero or one match ? zero or more match * one or more + Repetitions {} Greedy Matches & findall Character Classes Matching Newlines Review of regex Symbols

XML and JSON Processing

Loading XML data Traversing document tree Searching XML document Writing XML output Reading and Writing JSON output

Working with Excel

Working with Excel
example.xlsx
Getting Sheets from the Workbook
Getting Cells from the Sheets
Getting Rows and Columns from Sheets
Writing Excel Documents
Playing with Fonts
Dimensions
Merging Cells

Working with PDF & word documents

Working with .pdf & .docx
Extracting Text from PDFs
Rotating PDFs
Reading Word Documents
Driving the styles
Writing Word Documents

Web scraping

Web Scraping webbrowser module requests module BeautifulSoup CSS Selectors Finding an Element with the select() Method Getting data from an Element’s Attributes Controlling your browser with Selenium

Working with CSV and JSON

Working with CSV and JSON
Extracting Text from CSV files
Reader Objects in a for Loop
Writer Objects
Delimiters and line terminators
Reading JSON with loads()
Writing JSON with the dumps()
REST APIs and JSON
REST API returns

Keeping Time, Scheduling Task & Launching Programs

time Module
datetime Module
timedelta
datetime conversion to strings
strings to datetime objects
Threading

Sending Email & text messages

smtplib Module imapclient Module pyzmail Module Searching Email twilio

Networking with Python

Sockets Sending/receiving messages


Python Python Programming Python automation Python automating