100% found this document useful (1 vote)
281 views

Data Ingestion with Python Cookbook: A practical guide to ingesting, monitoring, and identifying errors in the data ingestion process 1st Edition Esppenchutz - Instantly access the full ebook content in just a few seconds

The document promotes the 'Data Ingestion with Python Cookbook' by Gláucia Esppenchutz, which serves as a practical guide for data ingestion processes. It includes links to download the book and other related resources, as well as information about the author and contributors. The book covers various aspects of data ingestion, including monitoring and error identification.

Uploaded by

prosipvuvu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
281 views

Data Ingestion with Python Cookbook: A practical guide to ingesting, monitoring, and identifying errors in the data ingestion process 1st Edition Esppenchutz - Instantly access the full ebook content in just a few seconds

The document promotes the 'Data Ingestion with Python Cookbook' by Gláucia Esppenchutz, which serves as a practical guide for data ingestion processes. It includes links to download the book and other related resources, as well as information about the author and contributors. The book covers various aspects of data ingestion, including monitoring and error identification.

Uploaded by

prosipvuvu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Visit ebookmass.

com to download the full version and


explore more ebook or textbook

Data Ingestion with Python Cookbook: A practical


guide to ingesting, monitoring, and identifying
errors in the data ingestion process 1st Edition
Esppenchutz
_____ Click the link below to download _____
https://ebookmass.com/product/data-ingestion-with-python-
cookbook-a-practical-guide-to-ingesting-monitoring-and-
identifying-errors-in-the-data-ingestion-process-1st-
edition-esppenchutz/

Explore and download more ebook or textbook at ebookmass.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Python Data Cleaning Cookbook - Second Edition Michael


Walker

https://ebookmass.com/product/python-data-cleaning-cookbook-second-
edition-michael-walker/

Data Engineering with dbt: A practical guide to building a


cloud-based, pragmatic, and dependable data platform with
SQL Zagni
https://ebookmass.com/product/data-engineering-with-dbt-a-practical-
guide-to-building-a-cloud-based-pragmatic-and-dependable-data-
platform-with-sql-zagni/

Exploratory Data Analysis with Python Cookbook: Over 50


recipes to analyze, visualize, and extract insights from
structured and unstructured data Oluleye
https://ebookmass.com/product/exploratory-data-analysis-with-python-
cookbook-over-50-recipes-to-analyze-visualize-and-extract-insights-
from-structured-and-unstructured-data-oluleye/

Data-Driven SEO with Python: Solve SEO Challenges with


Data Science Using Python 1st Edition Andreas Voniatis

https://ebookmass.com/product/data-driven-seo-with-python-solve-seo-
challenges-with-data-science-using-python-1st-edition-andreas-
voniatis/
Statistical Process Monitoring Using Advanced Data-Driven
and Deep Learning Approaches: Theory and Practical
Applications 1st Edition Fouzi Harrou
https://ebookmass.com/product/statistical-process-monitoring-using-
advanced-data-driven-and-deep-learning-approaches-theory-and-
practical-applications-1st-edition-fouzi-harrou/

Beginner's Guide to Streamlit with Python: Build Web-Based


Data and Machine Learning Applications 1st Edition Sujay
Raghavendra
https://ebookmass.com/product/beginners-guide-to-streamlit-with-
python-build-web-based-data-and-machine-learning-applications-1st-
edition-sujay-raghavendra/

Data Structure and Algorithms With Python: The Ultimate


Guide Towards Coding John Thomas

https://ebookmass.com/product/data-structure-and-algorithms-with-
python-the-ultimate-guide-towards-coding-john-thomas/

(eBook PDF) Intro to Python for Computer Science and Data


Science: Learning to Program with AI, Big Data and The
Cloud
https://ebookmass.com/product/ebook-pdf-intro-to-python-for-computer-
science-and-data-science-learning-to-program-with-ai-big-data-and-the-
cloud/

Nonclinical Study Contracting and Monitoring: A Practical


Guide 1st Edition

https://ebookmass.com/product/nonclinical-study-contracting-and-
monitoring-a-practical-guide-1st-edition/
Data Ingestion with Python
Cookbook

A practical guide to ingesting, monitoring, and identifying


errors in the data ingestion process

Gláucia Esppenchutz

BIRMINGHAM—MUMBAI
Data Ingestion with Python Cookbook
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case
of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express
or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable
for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and
products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.

Group Product Manager: Reshma Raman


Publishing Product Manager: Arindam Majumdar
Senior Editor: Tiksha Lad
Technical Editor: Devanshi Ayare
Copy Editor: Safis Editing
Project Coordinator: Farheen Fathima
Proofreader: Safis Editing
Indexer: Sejal Dsilva
Production Designer: Jyoti Chauhan
Marketing Coordinator: Nivedita Singh

First published: May 2023

Production reference: 1300523

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-83763-260-2

www.packtpub.com
This book represents a lot and wouldn’t be possible without my loving husband, Lincoln, and his
support and understanding during this challenging endeavor. I want to thank all my friends that
didn’t let me give up and always boosted my spirits, along with my grandmother, who always believed,
helped, and said I would do big things one day. Finally, I want to thank my beloved and four-pawed
best friend, who is at peace, Minduim, for “helping” me to write this book.

– Gláucia Esppenchutz
Contributors

About the author


Gláucia Esppenchutz is a data engineer with expertise in managing data pipelines and vast amounts
of data using cloud and on-premises technologies. She worked in companies such as Globo.com,
BMW Group, and Cloudera. Currently, she works at AiFi, specializing in the field of data operations
for autonomous systems.
She comes from the biomedical field and shifted her career ten years ago to chase the dream of
working closely with technology and data. She is in constant contact with the open source community,
mentoring people and helping to manage projects, and has collaborated with the Apache, PyLadies
group, FreeCodeCamp, Udacity, and MentorColor communities.

I want to thank my patient and beloved husband and my friends. Thanks also to my mentors in the
Python open source community and the DataBootCamp founders, who guided me at the beginning
of my journey.
Thanks to the Packt team, who helped me through some hard times; you were terrific!
About the reviewers
Bitthal Khaitan is currently working as a big data and cloud engineer with CVS Health, a Fortune
4 organization. He has a demonstrated history of working in the cloud, data and analytics industry
for 12+ years. His primary certified skills are Google Cloud Platform (GCP), the big data ecosystem
(Hadoop, Spark, etc.), and data warehousing on Teradata. He has worked in all phases of the SDLC
of DW/BI and big data projects with strong expertise in the USA healthcare, insurance and retail
domains. He actively helps new graduates with mentoring, resume reviews, and job hunting tips in
the data engineering domain. Over 20,000 people follow Bitthal on LinkedIn. He is currently based
out of Dallas, Texas, USA.
Jagjeet Makhija is a highly accomplished technology leader with over 20 years of experience. They are
skilled not only in various domains including AI, data warehouse architecture, and business analytics,
but also have a strong passion for staying ahead of technology trends such as AI and ChatGPT.
Jagjeet is recognized for their significant contributions to the industry, particularly in complex proof
of concepts and integrating Microsoft products with ChatGPT. They are also an avid book reviewer
and have actively shared their extensive knowledge and expertise through presentations, blog articles,
and online forums.
Krishnan Raghavan is an IT professional with over 20 years of experience in the area of software
development and delivery excellence across multiple domains and technology, ranging from C++ to
Java, Python, data warehousing, and big data tools and technologies. Krishnan tries to give back to the
community by being part of GDG – Pune Volunteer Group, helping the team in organizing events.
When not working, Krishnan likes to spend time with his wife and daughter, as well as reading fiction,
non-fiction, and technical books. Currently, he is unsuccessfully trying to learn how to play the guitar.
You can connect with Krishnan at mail to: k r i s h n a n @ g m a i l . c o m or via
LinkedIn: www.linkedin.com/in/krishnan-raghavan

I would like to thank my wife, Anita, and daughter, Ananya, for giving me the time and space to
review this book.
Table of Contents

Prefacexv

Part 1: Fundamentals of Data Ingestion


1
Introduction to Data Ingestion 3
Technical requirements 4 How to do it… 17
Setting up Python and its environment 4 How it works… 21
See also 22
Getting ready 4
How to do it… 5 Creating schemas 22
How it works… 7 Getting ready 22
There’s more… 7 How to do it… 22
See also 7 How it works… 24
Installing PySpark 8 See also 25

Getting ready 8 Applying data governance in ingestion 25


How to do it… 10 Getting ready 25
How it works… 12 How to do it… 26
There’s more… 12 How it works… 28
See also 12 See also 28
Configuring Docker for MongoDB 13 Implementing data replication 29
Getting ready 13 Getting ready 29
How to do it… 13 How to do it… 29
How it works… 14 How it works… 29
There’s more… 16 There’s more… 30
See also 16
Further reading 30
Configuring Docker for Airflow 16
Getting ready 17
viii Table of Contents

2
Principals of Data Access – Accessing Your Data 31
Technical requirements 31 How to do it… 47
Implementing governance in a data How it works… 48
access workflow 32 There’s more… 49
Getting ready 32 See also 52
How to do it… 33 Managing encrypted files 52
How it works… 34 Getting ready 52
See also 34 How to do it… 53
Accessing databases and data How it works… 54
warehouses34 There’s more… 55
Getting ready 35 See also 56
How to do it… 35 Accessing data from AWS using S3 56
How it works… 37 Getting ready 56
There’s more… 38 How to do it… 59
See also 39 How it works… 62
Accessing SSH File Transfer Protocol There’s more… 63
(SFTP) files 39 See also 63
Getting ready 39 Accessing data from GCP using
How to do it… 41 Cloud Storage 64
How it works… 43 Getting ready 64
There’s more… 43 How to do it… 66
See also 44 How it works… 68
Retrieving data using API There’s more… 70
authentication44 Further reading 70
Getting ready 45

3
Data Discovery – Understanding Our Data before Ingesting It 71
Technical requirements 71 How to do it… 73
Documenting the data discovery How it works… 77
process71 Configuring OpenMetadata 77
Getting ready 72 Getting ready 77
Table of Contents ix

How to do it… 79 Getting ready 86


How it works… 84 How to do it… 88
There’s more… 86 How it works… 92
See also 86
Further reading 93
Connecting OpenMetadata Other tools 94
to our database 86

4
Reading CSV and JSON Files and Solving Problems 95
Technical requirements 95 How it works… 105
Reading a CSV file 96 There’s more… 106
See also 107
Getting ready 96
How to do it… 96 Using PySpark to read CSV files 108
How it works… 98 Getting ready 108
There’s more… 98 How to do it… 108
See also 99 How it works… 109
Reading a JSON file 99 There’s more… 110
See also 114
Getting ready 100
How to do it… 100 Using PySpark to read JSON files 114
How it works… 100 Getting ready 114
There’s more… 101 How to do it… 115
See also 103 How it works… 116
Creating a SparkSession for PySpark 103 There’s more… 117
See also 117
Getting ready 103
How to do it… 104 Further reading 117

5
Ingesting Data from Structured and Unstructured Databases 119
Technical requirements 119 There’s more… 127
Configuring a JDBC connection 120 See also 129

Getting ready 120 Ingesting data from a JDBC database


How to do it… 124 using SQL 129
How it works… 126 Getting ready 129
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
x Table of Contents

How to do it… 130 Getting ready 146


How it works… 132 How to do it… 146
There’s more… 133 How it works… 148
See also 133 There’s more… 149
See also 150
Connecting to a NoSQL
database (MongoDB) 134 Ingesting data from MongoDB
Getting ready 134 using PySpark 150
How to do it… 136 Getting ready 150
How it works… 142 How to do it… 151
There’s more… 144 How it works… 153
See also 145 There’s more… 155
See also 156
Creating our NoSQL table in
MongoDB145 Further reading 157

6
Using PySpark with Defined and Non-Defined Schemas 159
Technical requirements 159 How to do it… 169
Applying schemas to data ingestion 160 How it works… 170

Getting ready 160 Ingesting unstructured data with a


How to do it… 162 well-defined schema and format 172
How it works… 163 Getting ready 172
There’s more… 165 How to do it… 172
See also 165 How it works… 174
Importing structured data using a There’s more… 176
well-defined schema 165 See also 176

Getting ready 165 Inserting formatted SparkSession


How to do it… 165 logs to facilitate your work 176
How it works… 167 Getting ready 176
There’s more… 168 How to do it… 176
See also 169 How it works… 178
Importing unstructured data without There’s more… 179
a schema 169 See also 179

Getting ready… 169 Further reading 179


Table of Contents xi

7
Ingesting Analytical Data 181
Technical requirements 181 How it works… 197
Ingesting Parquet files 182 There’s more… 198
See also 200
Getting ready 182
How to do it… 183 Ingesting partitioned data 200
How it works… 184 Getting ready 200
There’s more… 185 How to do it… 201
See also 185 How it works… 201
Ingesting Avro files 185 There’s more… 203
See also 204
Getting ready 186
How to do it… 186 Applying reverse ETL 204
How it works… 188 Getting ready 204
There’s more… 190 How to do it… 205
See also 190 How it works… 206
Applying schemas to analytical data 191 There’s more… 207
See also 207
Getting ready 191
How to do it… 191 Selecting analytical data for reverse
How it works… 194 ETL207
There’s more… 194 Getting ready 207
See also 195 How to do it… 208
Filtering data and handling common How it works… 209
issues195 See also 210

Getting ready 195 Further reading 210


How to do it… 196

Part 2: Structuring the Ingestion Pipeline


8
Designing Monitored Data Workflows 213
Technical requirements 213 Getting ready 214
Inserting logs 214 How to do it… 214
How it works… 216
xii Table of Contents

See also 217 How it works… 229


There’s more… 229
Using log-level types 217
See also 230
Getting ready 217
How to do it… 217 Logging based on data 231
How it works… 219 Getting ready 231
There’s more… 220 How to do it… 231
See also 221 How it works… 232
There’s more… 233
Creating standardized logs 221
See also 233
Getting ready 222
How to do it… 222 Retrieving SparkSession metrics 234
How it works… 224 Getting ready 234
There’s more… 227 How to do it… 234
See also 227 How it works… 237
There’s more… 241
Monitoring our data ingest file size 227
See also 242
Getting ready 228
How to do it… 228 Further reading 242

9
Putting Everything Together with Airflow 243
Technical requirements 244 How to do it… 257
Installing Airflow 244 How it works… 260
There's more… 262
Configuring Airflow 244 See also 262
Getting ready 244
How to do it… 245 Configuring sensors 262
How it works… 247 Getting ready 262
See also 248 How to do it… 263
How it works… 264
Creating DAGs 248 See also 265
Getting ready 248
How to do it… 249 Creating connectors in Airflow 265
How it works… 253 Getting ready 266
There's more… 254 How to do it… 266
See also 255 How it works… 269
There's more… 270
Creating custom operators 255 See also 270
Getting ready 255
Table of Contents xiii

Creating parallel ingest tasks 270 Getting ready 274


Getting ready 270 How to do it… 275
How to do it… 271 How it works… 277
How it works… 272 There's more… 278
There's more… 273 See also 279
See also 274
Further reading 279
Defining ingest-dependent DAGs 274

10
Logging and Monitoring Your Data Ingest in Airflow 281
Technical requirements 281 Designing advanced monitoring 304
Installing and running Airflow 282 Getting ready 304
How to do it… 306
Creating basic logs in Airflow 283
How it works… 308
Getting ready 284
There’s more… 309
How to do it… 284
See also 309
How it works… 287
See also 289 Using notification operators 309
Getting ready 310
Storing log files in a remote location 289
How to do it… 312
Getting ready 289
How it works… 315
How to do it… 290
There’s more… 318
How it works… 298
See also 299 Using SQL operators for data quality 318
Getting ready 318
Configuring logs in airflow.cfg 299
How to do it… 320
Getting ready 299
How it works… 321
How to do it… 299
There’s more… 323
How it works… 301
See also 323
There’s more… 303
See also 304 Further reading 324

11
Automating Your Data Ingestion Pipelines 325
Technical requirements 325 Scheduling daily ingestions 326
Installing and running Airflow 326 Getting ready 327
xiv Table of Contents

How to do it… 327 There's more… 340


How it works… 330
Setting up the schedule_interval
There's more… 330
parameter340
See also 331
Getting ready 340
Scheduling historical data ingestion 331 How to do it… 341
Getting ready 331 How it works… 342
How to do it… 332 See also 342
How it works… 335
Solving scheduling errors 343
There's more… 336
Getting ready 343
Scheduling data replication 337 How to do it… 343
Getting ready 337 How it works… 346
How to do it… 338 There’s more… 347
How it works… 339
Further reading 347

12
Using Data Observability for Debugging, Error Handling,
and Preventing Downtime 349
Technical requirements 349 Getting ready 358
Docker images 350 How to do it… 358
How it works… 361
Setting up StatsD for monitoring 351 There’s more… 363
Getting ready 351
How to do it… 351 Creating an observability dashboard 363
How it works… 353 Getting ready 363
See also 354 How to do it… 363
How it works… 369
Setting up Prometheus for storing There’s more… 370
metrics354
Getting ready 354 Setting custom alerts or notifications 370
How to do it… 354 Getting ready 371
How it works… 356 How to do it… 371
There’s more… 357 How it works… 377

Setting up Grafana for monitoring 358 Further reading 378

Index379

Other Books You May Enjoy 388


Preface
Welcome to Data Ingestion with Python Cookbook. I hope you are excited as me to enter the world
of data engineering.
Data Ingestion with Python Cookbook is a practical guide that will empower you to design and implement
efficient data ingestion pipelines. With real-world examples and renowned open-source tools, this
book addresses your queries and hurdles head-on.
Beginning with designing pipelines, you’ll explore working with and without data schemas, constructing
monitored workflows using Airflow, and embracing data observability principles while adhering
to best practices. Tackling the challenges of reading diverse data sources and formats, you’ll gain a
comprehensive understanding of all these.
Our journey continues with essential insights into error logging, identification, resolution, data
orchestration, and effective monitoring. You’ll discover optimal approaches for storing logs, ensuring
easy access and references for them in the future.
By the end of this book, you’ll possess a fully automated setup to initiate data ingestion and pipeline
monitoring. This streamlined process will seamlessly integrate into the subsequent stages of the Extract,
Transform, and Load (ETL) process, propelling your data integration capabilities to new heights. Get
ready to embark on an enlightening and transformative data ingestion journey.

Who this book is for


This comprehensive book is specifically designed for Data Engineers, Data Integration Specialists, and
passionate data enthusiasts seeking a deeper understanding of data ingestion processes, data flows,
and the typical challenges encountered along the way. It provides valuable insights, best practices, and
practical knowledge to enhance your skills and proficiency in handling data ingestion tasks effectively.
Whether you are a beginner in the data world or an experienced developer, this book will suit you.
It is recommended to know the Python programming fundamentals and have basic knowledge of
Docker to read and run this book’s code.

What this book covers


Chapter 1, Introduction to Data Ingestion, introduces you to data ingestion best practices and the
challenges of working with diverse data sources. It explains the importance of the tools covered in
the book, presents them, and provides installation instructions.
xvi Preface

Chapter 2, Data Access Principals – Accessing your Data, explores data access concepts related to data
governance, covering workflows and management of familiar sources such as SFTP servers, APIs,
and cloud providers. It also provides examples of creating data access policies in databases, data
warehouses, and the cloud.
Chapter 3, Data Discovery – Understanding Our Data Before Ingesting It, teaches you the significance of
carrying out the data discovery process before data ingestion. It covers manual discovery, documentation,
and using an open-source tool, OpenMetadata, for local configuration.
Chapter 4, Reading CSV and JSON Files and Solving Problems, introduces you to ingesting CSV and JSON
files using Python and PySpark. It demonstrates handling varying data volumes and infrastructures
while addressing common challenges and providing solutions.
Chapter 5, Ingesting Data from Structured and Unstructured Databases, covers fundamental concepts
of relational and non-relational databases, including everyday use cases. You will learn how to read
and handle data from these models, understand vital considerations, and troubleshoot potential errors.
Chapter 6, Using PySpark with Defined and Non-Defined Schemas, delves deeper into common PySpark
use cases, focusing on handling defined and non-defined schemas. It also explores reading and
understanding complex logs from Spark (PySpark core) and formatting techniques for easier debugging.
Chapter 7, Ingesting Analytical Data, introduces you to analytical data and common formats for reading
and writing. It explores reading partitioned data for improved performance and discusses Reverse
ETL theory with real-life application workflows and diagrams.
Chapter 8, Designing Monitored Data Workflows, covers logging best practices for data ingestion,
facilitating error identification, and debugging. Techniques such as monitoring file size, row count,
and object count enable improved monitoring of dashboards, alerts, and insights.
Chapter 9, Putting Everything Together with Airflow, consolidates the previously presented information
and guides you in building a real-life data ingestion application using Airflow. It covers essential
components, configuration, and issue resolution in the process.
Chapter 10, Logging and Monitoring Your Data Ingest in Airflow, explores advanced logging and
monitoring in data ingestion with Airflow. It covers creating custom operators, setting up notifications,
and monitoring for data anomalies. Configuration of notifications for tools such as Slack is also covered
to stay updated on the data ingestion process.
Chapter 11, Automating Your Data Ingestion Pipelines, focuses on automating data ingests using
previously learned best practices, enabling reader autonomy. It addresses common challenges with
schedulers or orchestration tools and provides solutions to avoid problems in production clusters.
Chapter 12, Using Data Observability for Debugging, Error Handling, and Preventing Downtime,
explores data observability concepts, popular monitoring tools such as Grafana, and best practices
for log storage and data lineage. It also covers creating visualization graphs to monitor data source
issues using Airflow configuration and data ingestion scripts.
Preface xvii

To get the most out of this book


To execute the code in this book, you must have at least a basic knowledge of Python. We will use
Python as the core language to execute the code. The code examples have been tested using Python
3.8. However, it is expected to still work with future language versions.
Along with Python, this book uses Docker to emulate data systems and applications in our local
machine, such as PostgreSQL, MongoDB, and Airflow. Therefore, a basic knowledge of Docker is
recommended to edit container image files and run and stop containers.
Please, remember that some command-line commands may need adjustments depending on your local
settings or operating system. The commands in the code examples are based on the Linux command-
line syntax and might need some adaptations to run on Windows PowerShell.

Software/Hardware covered in the book OS Requirements

Python 3.8 or higher Windows, Mac OS X, and Linux (any)


Docker Engine 24.0 / Docker Desktop 4.19 Windows, Mac OS X, and Linux (any)

For almost all recipes in this book, you can use a Jupyter Notebook to execute the code. Even though it
is not mandatory to install it, this tool can help you to test the code and try new things on the code due
to the friendly interface.
If you are using the digital version of this book, we advise you to type the code yourself or access
the code via the GitHub repository (link available in the next section). Doing so will help you
avoid any potential errors related to the copying and pasting of code.

Download the example code files


You can download the example code files for this book from GitHub at https://github.com/
PacktPublishing/Data-Ingestion-with-Python-Cookbook. In case there’s an update
to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://
github.com/PacktPublishing/. Check them out!

Download the color images


We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You
can download it here: https://packt.link/xwl0U
xviii Preface

Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file
extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Then
we proceeded with the with open statement.”
A block of code is set as follows:

def gets_csv_first_line (csv_file):


    logging.info(f"Starting function to read first line")
    try:
        with open(csv_file, 'r') as file:
            logging.info(f"Reading file")

Any command-line input or output is written as follows:

$ python3 –-version
Python 3.8.10

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words
in menus or dialog boxes appear in the text like this. Here is an example: “Then, when we selected
showString at NativeMethodAccessorImpl.java:0, which redirected us to the
Stages page.”

Tips or important notes


Appear like this.

Sections
In this book, you will find several headings that appear frequently (Getting ready, How to do it..., How
it works..., There’s more..., and See also).
To give clear instructions on how to complete a recipe, use these sections as follows:

Getting ready
This section tells you what to expect in the recipe and describes how to set up any software or any
preliminary settings required for the recipe.

How to do it…
This section contains the steps required to follow the recipe.
Preface xix

How it works…
This section usually consists of a detailed explanation of what happened in the previous section.

There’s more…
This section consists of additional information about the recipe in order to make you more knowledgeable
about the recipe.

See also
This section provides helpful links to other useful information for the recipe.

Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the
subject of your message and email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen.
If you have found a mistake in this book, we would be grateful if you would report this to us. Please
visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata
Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would
be grateful if you would provide us with the location address or website name. Please contact us at
[email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you
are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Other documents randomly have
different content
mental endowments just enumerated, not only to obviate disgust,
but to excite extraordinary admiration.
One of the most prominent and detestable vices indeed, in
Richard's character, his hypocrisy, connected, as it always is, in his
person, with the most profound skill and dissimulation, has, owing to
the various parts which it induces him to assume, most materially
contributed to the popularity of this play, both on the stage, and in
the closet. He is one who can

—— "frame his face to all occasions,"[374:B]

and accordingly appears, during the course of his career, under the
contrasted forms of a subject and a monarch, a politician and a wit,
a soldier and a suitor, a sinner and a saint; and in all with such
apparent ease and fidelity to nature, that while to the explorer of the
human mind he affords, by his penetration and address, a subject of
peculiar interest and delight, he offers to the practised performer a
study well calculated to call forth his fullest and finest exertions. He,
therefore, whose histrionic powers are adequate to the just
exhibition of this character, may be said to have attained the highest
honours of his profession; and, consequently, the popularity of
Richard the Third, notwithstanding the moral enormity of its hero,
may be readily accounted for, when we recollect, that the versatile
and consummate hypocrisy of the tyrant has been embodied by the
talents of such masterly performers as Garrick, Kemble, Cook, and
Kean.
So overwhelming and exclusive is the character of Richard, that
the comparative insignificancy of all the other persons of the drama
may be necessarily inferred; they are reflected to us, as it were,
from his mirror, and become more or less important, and more or
less developed, as he finds it necessary to act upon them; so that
our estimate of their character is entirely founded on his relative
conduct, through which we may very correctly appreciate their
strength or weakness.
The only exception to this remark is in the person of Queen
Margaret, who, apart from the agency of Richard, and dimly seen in
the darkest recesses of the picture, pours forth, in union with the
deep tone of this tragedy, the most dreadful curses and
imprecations; with such a wild and prophetic fury, indeed, as to
involve the whole scene in tenfold gloom and horror.
We have to add that the moral of this play is great and
impressive. Richard, having excited a general sense of indignation,
and a general desire of revenge, and, unaware of his danger from
having lost, through familiarity with guilt, all idea of moral obligation,
becomes at length the victim of his own enormous crimes; he falls
not unvisited by the terrors of conscience, for, on the eve of danger
and of death, the retribution of another world is placed before him;
the spirits of those whom he had murdered, reveal the awful
sentence of his fate, and his bosom heaves with the infliction of
eternal torture.
11. King Richard the Second: 1596. Our great poet having been
induced to improve and re-compose the Dramatic History of Henry
the Sixth, and to continue the character of Gloucester to the close of
his usurpation, in the drama of Richard the Third, very naturally,
from the success which had crowned these efforts, reverted to the
prior part of our national story for fresh subjects, and, led by a
common principle of association, selected for the commencement of
a new series of historical plays, which should form an unbroken
chain with those that he had previously written, the reign of Richard
the Second. On this account, therefore, and from the intimation of
time, noticed by Mr. Chalmers, towards the conclusion of the first
[376:A]act, we are led to coincide with this gentleman in assigning

the composition of Richard the Second to the year 1596.


Of the character of this unfortunate young prince, Shakspeare has
given us a delineation in conformity with the general tone of history,
but heightened by many exquisite and pathetic touches. Richard was
beautiful in his person, and elegant in his manners[376:B];
affectionate, generous, and faithful in his attachments, and though
intentionally neglected in his education, not defective in
understanding. Accustomed, by his designing uncles, to the
company of the idle and the dissipated, and to the unrestrained
indulgence of his passions, we need not wonder that levity,
ostentation, and prodigality, should mark his subsequent career, and
should ultimately lead him to destruction.
Though the errors of his misguided youth are forcibly depicted in
the drama, yet the poet has reserved his strength for the period of
adversity. Richard, descending from his throne, discovers the
unexpected virtues of humility, fortitude, and resignation, and
becomes not only an object of love and pity, but of admiration; and
there is nothing in the whole compass of our author's plays better
calculated to produce, with full effect, these mingled emotions of
compassion and esteem, than the passages which paint the
sentiments and deportment of the fallen monarch. Patience,
submission, and misery, were never more feelingly expressed than in
the following lines:

"K. Rich. What must the king do now? Must he submit?


The king shall do it. Must he be depos'd?
The king shall be contented: Must he lose
The name of king? o'God's name, let it go:
I'll give my jewels, for a set of beads;
My gorgeous palace, for a hermitage;
My gay apparel, for an alms-man's gown:
My figur'd goblets, for a dish of wood;
My scepter, for a palmer's walking staff;
My subjects, for a pair of carved saints;
And my large kingdom for a little grave,
A little, little grave, an obscure grave:—
Or I'll be buried in the king's highway,
Some way of common trade, where subjects'
feet
May hourly trample on their sovereign's head:"
[377:A]

and with what an innate nobility of heart does he repress the


homage of his attendants!

"Cover your heads, and mock not flesh and blood


With solemn reverence; throw away respect,
Tradition, form, and ceremonious duty,
For you have but mistook me all this while:
I live with bread like you, feel want, taste grief,
Need friends:—Subjected thus,
How can you say to me—I am a king?"[377:B]

Nor does his conduct, in the hour of suffering and extreme


humiliation, derogate from the philosophy of his sentiments. In that
admirable opening of the second scene of the fifth act, where the
Duke of York relates to his Duchess the entrance of Bolingbroke and
Richard into London, the demeanour of the latter is thus pourtrayed:

————————————— "Men's eyes


Did scowl on Richard; no man cried, God save him;
No joyful tongue gave him his welcome home:
But dust was thrown upon his sacred head;
Which with such gentle sorrow he shook off,—
His face still combating with tears and smiles,
The badges of his grief and patience,—
That had not God, for some strong purpose, steel'd
The hearts of men, they must perforce have melted,
And barbarism itself have pitied him."[378:A]

In representing Richard as falling by the hand of Sir Piers of


Exton, Shakspeare has followed the Chronicle of Holinshed; but
there can be no doubt but this unhappy monarch either starved
himself under the influence of despair, or was starved by the cruelty
of his enemies. If in the account which Speed has given us of this
tragedy, the most complete that we possess, the relation of Polydore
Virgil be correct, nothing can be conceived more diabolical than the
conduct of Henry and his agents. "His diet being served in," says
that historian, "and set before him in the wonted Princely manner,
hee was not suffered either to taste, or touch thereof." "Surely,"
adds Speed, in a manner which reflects credit on his sensibility, "hee
is not a man who at the report of so exquisite a barbarisme, as
Richard's enfamishment, feeles not chilling horror and detestation;
what if but for a justly condemned galley-slave so dying? but how
for an annointed King whose character (like that of holy orders) is
indeleble?"[378:B]
Of the secondary characters of this play, "Old John of Gaunt,
time-honour'd Lancaster," and his son Henry Bolingbroke, are
brought forward with strict attention to the evidence of history; the
chivalric spirit, and zealous integrity of the first, and the cold,
artificial features of the second, being struck off with great
sharpness of outline, and strength of discrimination.
12. Henry the Fourth; Part the First: 1596;
13. Henry the Fourth; Part the Second: 1596:
That both these plays were written in the year 1596, will, we
think, appear from consulting the arguments and quotations
adduced by Mr. Malone to prove them the compositions of 1597 and
1598, and by Mr. Chalmers with the view of assigning them to the
years 1596 and 1597; for while the latter gentleman has rendered it
most probable, from the allusions which he has noticed in the play
itself, that the First Part was written in 1596, the authorities and
citations produced by the former, for the assignment of the Second
Part to the year 1598, almost necessarily refer it, strange as it may
appear, with only one exception[379:A], and that totally indecisive, to
the very same year which witnessed the composition of its
predecessor, namely 1596! Influenced by this result, and by the
observation of Dr. Johnson, that these dramas appear "to be two,
only because they are too long to be one[379:B]," we have placed
them under the same year, convinced, with Mr. Malone, that they
could not be written before 1596; and induced, from the arguments
to which he, and his immediate successor in chronological research
have advanced, though with a different object, to consider them as
not written after that period.[379:C]
The inimitable genius of Shakspeare is no where more
conspicuous than in the construction of these dramas, whether we
consider the serious or the comic parts. In the former, which involve
occurrences of the highest interest in a national point of view, the
competition, and we may say, the contrast between Percy and the
Prince of Wales, is supported with unrivalled talent and
discrimination. Full of a fiery and uncontrollable courage, mingled
with a portion of arrogance and spleen, generous, chivalric, and
open, and breathing throughout a lofty, and even sublime spirit,
Hotspur appears before us a youthful model of enthusiastic and
impetuous heroism.
Yet, noble and exciting as this character must be pronounced,
notwithstanding the very obvious alloy of a vindictive and
ungovernable temper, it is completely overshadowed by that which is
attributed to the Prince of Wales; a result which may, with a perfect
conviction of certainty, be ascribed to the combination of two very
powerful causes,—to the rare union, in fact, of great and varied
intellectual energy, with the utmost amiability of disposition. Percy
has but the virtues and accomplishments of a military adventurer, for
in society he is boisterous, self-willed, and unaccommodating; while
Henry, to bravery equally gallant and undaunted, adds all the
endearing arts of social intercourse. He is gay, witty, gentle, and
good-tempered, with such a high relish for humour and frolic as to
lead him, through an over-indulgence of this propensity, into
numerous scenes of dissipation and idleness, and into a familiarity
with persons admirably well calculated, it is true, for the gratification
of the most fertile and comic imagination, but who, in every moral
and useful light, are altogether worthless and degraded.
From the contaminating influence of such dangerous connections,
he is rescued by the vigour of his mind, and the goodness of his
heart; for, possessing a clear and unerring conception of the
character of Falstaff and his associates, though he tolerate their
intimacy from a reprehensible love of wit and humour, he beholds,
with a consciousness of self-abasement, the depravity of their
principles, and is guarded against any durable injury or impression
from these dissolute companions of his sport.
The effect, however, of this temporary delusion is both in a moral
and dramatic light, singularly striking; contemned and humiliated in
the eyes of those who surround him, little expectancy is entertained,
not even by the King himself, of any permanently vigorous or
dignified conduct in his son; for though he has, more than once,
exhibited himself equal to the occasion, however great, which has
called him forth, he has immediately relapsed into his former wild
and eccentric habits. When, therefore, annihilating the gloom which
has hitherto obscured his lustre, and shaking off his profligate
companions like "dew-drops from the lion's mane," he comes
forward, strong in moral resolution, dignified without effort, firm
without ostentation, and consistent without a sense of sacrifice, a
denouement is produced, at once great, satisfactory, and splendid.
[381:A]

If the serious parts of these plays, however, be powerful and


characteristic, the comic portion is still more entitled to our
admiration, being rich, original, and varied, in a degree unparalleled
by any other writer.
There never was a character drawn, perhaps, so complete and
individualized as that of Falstaff, nor one in which so many
contrasted qualities are rendered subservient to the production of
the highest entertainment and delight. In the compound, however, is
to be found neither atrocious vices, nor any decided moral virtues; it
is merely a tissue, though woven with matchless skill, of the
agreeable and the disagreeable, the former so preponderating as to
stamp the result with the power of imparting pleasurable emotion.
Sensuality, under all its forms, is the vice of Falstaff; wit and
gaiety are his virtues.
As to gratify his animal appetites, therefore, is the sole end and
aim of his being, every faculty of his mind and body is directed
exclusively to this purpose, and he is no further vicious, no further
interesting and agreeable than may be necessary to the acquisition
of his object. Had he succeeded but partially in the attainment of his
views, and consequently by the means usually put in practice, he
would have been contemptible, loathsome, and disgusting, but he
has succeeded to an extent beyond all other men, and therefore by
means of an extraordinary kind, and which have covered the fruition
of his plans with an adventitious and even fascinating lustre.
The perfect Epicurism, in short, which he cultivates, requires for
the obtention of its gratifications a multitude of brilliant and
attractive qualifications; for, in order to run the full career of sensual
enjoyment, associated as he was with a man of high rank, and
considerable mental powers, it was necessary that he should render
himself both highly acceptable and interesting, that he should
assume the appearance or pretend to the possession of several
virtues, and that he should be guilty of no very revolting or
disgustful intemperance.
To perform this task, however, with unfailing effect, demanded,
on the part of Falstaff, incessant intellectual vigour, and a perpetual
command of temper, and these Shakspeare has bestowed upon him
in their full plenitude. His wit is inexhaustible, his gaiety and good-
humour undeviating, his address shrewd and discriminating, and, as
the favourable opinion of his associates is, to a certain extent,
essential to his enjoyments, he endeavours to impress the prince
with confidence in his friendship and courage, his gratitude and
fidelity, and to impose on his equals and inferiors a sense of his
military and political importance. It is also requisite that, though an
incorrigible lover of wine, of dainty fare, and of all libidinous delights,
he should exhibit nothing either as the accompaniment or
consequence of these pursuits, which should be beastly or
loathsome; he is, therefore, never represented as in a state of
intoxication, nor loaded with more infirmities than what corpulency
produces; but is always himself, crafty, sprightly, selfish, and
intelligent, ever ready to invent and to enjoy the sport, the revel,
and the jest.
Thus constituted, his social and intellectual qualities so blending
with the dissolute propensities of his nature, that the epicure, and
free-booter, the whore-monger and vain-glorious boaster, lose in the
composition their native deformity, Falstaff becomes the most
entertaining and seductive companion that the united powers of
genius, levity, and laughter have ever, in the most felicitous hour of
their mirth and fancy, created for the sons of men.
Yet, dangerous as such a delineation may appear, Shakspeare,
with his usual attention to the best interests of mankind, has
rendered it subservient to the most striking moral effects, both as
these apply to the character of Falstaff himself, and to that of his
temporary patron, the Prince of Wales; for while the virtue, energy,
and good sense of the latter are placed in the most striking point of
view by his firm dismissal of a most fascinating and too endeared
voluptuary, the permanently degrading consequences of sensuality
are exhibited in their full strength during the career, and in the fate,
of the former.
It is very generally found that great and splendid vices are
mingled with concomitant virtues, which often ultimately lead to self-
accusation, and to the salutary agonies of remorse; but he who is
deeply plunged in the grovelling pursuits of appetite is too frequently
lost to all sense of shame, to all feeling of integrity or conscious
worth. Polluted by the meanest depravities, not only religious
principle ceases to affect the mind, but every thing which contributes
to honour or to grandeur in the human character is gone for ever; a
catastrophe to which wit and humour, by rendering the sensualist a
more self-deluded and self-satisfied being, lend the most powerful
assistance.
Thus is it with Falstaff—to the last he remains the same,
unrepentant, unreformed; and, though shaken off by all that is
valuable or good around him, dies the very sensualist which he had
lived!
We may, therefore, derive from this character as much instruction
as entertainment; and, to the delight which we receive from the
contemplation of a picture so rich and original, add a lesson of
morality as aweful and impressive as the history of human frailty can
present.
In order fully to unfold the extraordinary character of Falstaff, it
was necessary to throw around him a set of familiar associates, who
might, through all the privacies of domestic life, lay open his follies
and knaveries, while, at the same time, they themselves contributed,
in no small degree, to the amusement of the scene. How admirably
the poet has succeeded in this design, the spirited and glowing
sketches of Bardolph, Pistol, and Mrs. Quickly, and of Justices
Shallow and Silence, will bear an ever-during testimony. Than the
scenes in which the two magistrates appear, nothing can be
conceived more characteristically pleasant and original. The garrulity,
vanity, and knavish simplicity of Shallow; the asinine gravity of
Silence when sober, and his irrepressible hilarity when tipsy;
Falstaff's exquisite appreciation of their characters, and his
patronage of Shallow, are presented to us with a naïveté, raciness,
and completeness of conception, which it is in vain to look for
elsewhere.
We have further to remark, that the fable of the Two Parts of
Henry the Fourth is connected with peculiar skill through the
intervention of the comic incidents. It was essential, in fact, for the
purposes of representation, that there should be a satisfactory close
to each Part, while, at the same time, such a medium of
communication should exist between the two, as to form a perfect
whole. To effect this, the serious and the ludicrous departments of
these dramas are conducted in a different way; the former exhibiting
two catastrophes while the latter has but one. Thus the death of
Percy in the first play, and the death of Henry the Fourth in the
second, form two judicious terminations of the tragic portion, while
the rich vein of comedy running through both divisions, is only
bounded by the Reformation of Henry the Fifth, and the Fall of his
vicious but facetious companion; a denouement at once natural and
complete, and springing from intrinsic causes, being the sole result
of firmness and penetration in the prince, and of self-delusion in the
knight.
14. The Merchant of Venice: 1597. We are inclined to prefer this
date to that of 1598, in consequence of the two allusions to time
noticed by Mr. Chalmers in his Chronology[385:A]; and which, as the
epoch formerly fixed on by the commentators was founded merely
on the fact of this play being registered on the 22d of July, 1598, a
circumstance perfectly indecisive as to the period of its composition,
ought consequently to possess the privilege of establishing its era.
Of the three plots which constitute this very interesting drama,
namely that of the Caskets, that of the Bond, and that of the
Elopement of Jessica, the first two appear to have formed the fable
of a play entitled The Jew, long anterior to our author's production.
"The Jew shown at the Bull," says Gosson in his School of Abuse,
1579, "representing the greediness of worldly choosers, and the
bloody minds of usurers——these plays," says he, mentioning others
at the same time, "are goode and sweete plays."[385:B]
Now, there can be no doubt that Shakspeare, in conformity to his
usual custom, would avail himself of the labours of this his dramatic
predecessor; but it is also evident that he had other resources. "The
author of the old play of The Jew," observes Mr. Douce, "and
Shakspeare in his Merchant of Venice, have not confined themselves
to one source only in the construction of their plot; but, that the
Pecorone, the Gesta Romanorum, and perhaps the old Ballad of
Gernutus, have been respectively resorted to. It is however most
probable that the original play was indebted chiefly, if not altogether
to the Gesta Romanorum, which contained both the main incidents;
and that Shakspeare expanded and improved them, partly from his
own genius, and partly, as to the bond, from the Pecorone, where
the coincidences are too manifest to leave any doubt. Thus, the
scene being laid at Venice; the residence of the lady at Belmont; the
introduction of a person bound for the principal; the double
infraction of the bond, viz., the taking more or less than a pound of
flesh and the shedding of blood, together with the after-incident of
the ring, are common to the novel and the play. The whetting of the
knife might perhaps have been taken from the Ballad of Gernutus.
Shakspeare was likewise indebted to an authority that could not
have occurred to the original author of the play in an English form;
this was, Silvayn's Orator, as translated by Munday. From that work
Shylock's reasoning before the senate is evidently borrowed; but at
the same time it has been most skilfully improved."[386:A]
The Orator of Silvayn, translated by Munday from the French, was
printed by Adam Islip in 1596, and forms one of Mr. Chalmers's
authorities for assigning the composition of the Merchant of Venice
to the year 1597.
Of the two English Gesta mentioned by Mr. Douce, that containing
the story of the Bond is as old as the reign of Henry the Sixth, and
though now only known to exist in manuscript[386:B], might probably
have been in print in the time of Shakspeare and the author of the
elder play.
The Gesta, including the story of the Caskets, there is reason to
think, was translated by Leland and revised by R. Robinson; for a
memorandum relative to the first edition of the improved version,
written by Robinson himself, and occurring in his Eupolemia, is thus
worded:—"1577. A record of ancyent historyes intituled in Latin
Gesta Romanorum, translated (auctore ut supponitur Johane
Leylando antiquario) by mee perused corrected and bettered.
Perused further by the wardens of the stationer's and printed first
and last by Thomas Easte."[386:C] If the supposition here recorded
be correct, it is highly probable that Leland's translation is identical
with that referred to by Mr. Warton and Dr. Farmer[387:A] as printed
by Wynkyn de Worde without date; though it must be remarked,
that neither Mr. Herbert, nor Mr. Douce, nor Mr. Dibdin has been
fortunate enough to discover such an impression.[387:B]
As many of the incidents in the Bond story of the Merchant of
Venice possess a more striking resemblance to the first tale of the
fourth day in the Pecorone of Ser Giovanni, than to either the Gesta,
the Ballad of Gernutus, or the Orator of Silvayn, the probability is,
that a version of this tale, if not of the entire collection, was extant
in Shakspeare's days. Il Pecorone, though written almost two
centuries before, was not published until 1558, when the first edition
came forth at Milan.
The love and elopement of Jessica and Lorenzo have been
noticed by Mr. Dunlop as bearing a similitude to the fourteenth tale
of the second book of the Novellino of Massuccio Di Salerno[387:C];
but it must be recollected, that until the play alluded to by Gosson
can be produced, it is impossible to ascertain to whom Shakspeare is
most peculiarly indebted for the materials of his complicated plot.
There is much reason to conclude, however, that the felicitous
union of the two principal actions of this drama, that concatenation
of cause and effect, which has formed them into a whole, is to be
ascribed, almost exclusively, to the judgment and the art of
Shakspeare. There is also another unity of equal moment, seldom
found wanting, indeed, in any of the genuine plays of our poet, but
which is particularly observable in this, that unity of feeling which we
have once before had occasion to notice, and which, in the present
instance, has given an uniform, but an extraordinary, tone to every
part of the fable. Thus the unparalleled nature of the trial between
the Jew and his debtor, required, in order to produce that species of
dramatic consistency so essential to the illusion of the reader or
spectator, that the other important incident of the piece should
assume an equal cast of singularity; the enigma, therefore, of the
caskets is a most suitable counterpart to the savage eccentricity of
the bond, and their skilful combination effects the probability arising
from similitude of nature and intimacy of connection.
Yet the ingenuity of the fable is surpassed by the truth and
originality of the characters that carry it into execution. Avarice and
revenge, the prominent vices of Shylock, are painted with a pencil so
discriminating, as to appear very distinct from the same passions in
the bosom of a Christian. The peculiar circumstances, indeed, under
which the Jews have been placed for so many centuries, would of
themselves be sufficient, were the national feelings correctly caught,
to throw a peculiar colouring over all their actions and emotions; but
to these were unhappily added, in the age of Shakspeare, the most
rooted prejudices and antipathies; an aversion, indeed, partaking of
hatred and horror, was indulged against this persecuted people, and
consequently the picture which Shakspeare has drawn exhibits not
only a faithful representation of Jewish sentiments and manners, the
necessary result of a singular dispensation of Providence, but it
embodies in colours, of almost preternatural strength, the Jew as he
appeared to the eye of the shuddering Christian.
In Shylock, therefore, while we behold the manners and the
associations of the Hebrew mingling with every thing he says and
does, and touched with a verisimilitude and precision which excite
our astonishment, we, at the same time, perceive, that, influenced
by the prepossessions above-mentioned, the poet has clothed him
with passions which would not derogate from a personification of the
evil principle itself. He is, in fact, in all the lighter parts of his
character, a generical exemplar of Judaism, but demonized,
individualized, and rendered awfully striking and horribly appalling
by the attribution of such unrelenting malice, as we will hope, for the
honour of our species, was never yet accumulated, with such
intensity, in any human breast.
So vigorous, however, so masterly is the delineation of this
Satanic character, and so exactly did it, until of late years, chime in
with the bigotry of the Christian world, that no one of our author's
plays has experienced greater popularity. Fortunately the time has
now arrived when the Jew and the Christian can meet with all the
feelings of humanity about them; a state of society which, more
than any other, is calculated to effect that conversion for which every
disciple of our blessed religion will assuredly pray.
There is, also, to be found in this beautiful play a charm for the
most gentle and amiable minds, a vein of dignified melancholy and
pensive sweetness which endears it to every heart, and which
fascinates the more as affording the most welcome relief to the
merciless conduct of its leading character. What, for instance, can be
more soothing and delightful to the feelings, than the generous and
disinterested friendship of Antonio, when contrasted with the hard
and selfish nature of Shylock; what more noble than the sublime
resignation of the merchant, when opposed to the deadly and
relentless hatred of his prosecutor! Never was friendship painted
more intense and lovely than in the parting scene of Antonio and
Bassanio; Salarino, speaking of the former, says,—

"A kinder gentleman treads not the earth.


I saw Bassanio and Antonio part:
Bassanio told him, he would make some speed
Of his return: he answer'd—'Do not so,
Slubber not business for my sake, Bassanio,
But stay the very riping of the time;
And for the Jew's bond, which he hath of me,
Let it not enter in your mind of love:
Be merry; and employ your chiefest thoughts
To courtship, and such fair ostents of love
As shall conveniently become you there:'
And even there, his eye being big with tears,
Turning his face, he put his hand behind him,
And with affection wond'rous sensible
He wrung Bassanio's hand, and so they parted.

Salanio. I think, he only loves the world for him."


[389:A]

Nor do the female personages of the drama contribute less to this


grateful effect: the sensible, the spirited, the eloquent Portia, who
has a principal share in the business of both plots, is equally
distinguished for the tenderness of her disposition and the goodness
of her heart, and her pleadings for mercy in behalf of the injured
Antonio will dwell on the ear of pity and admiration to the last
syllable of recorded time.
With a similar result do we enter into the character of Jessica,
whose artlessness, simplicity, and affectionate temper, excite, in an
uncommon degree, the interest of the reader. The opening of the
fifth act, where Lorenzo and Jessica are represented conversing on a
summer's night, in the avenue at Belmont, and listening with rapture
to the sounds of music, produces, occurring as it does immediately
after the soul-harrowing scene in the court of justice, the most
enchanting emotion; it breathes, indeed, a repose so soft and
delicious, that the mind seems dissolving in tranquil luxury:

"How sweet the moon-light sleeps upon this bank!


Here will we sit, and let the sounds of musick
Creep in our ears; soft stillness, and the night,
Become the touches of sweet harmony."[390:A]
Shakspeare was an enthusiast in music in a musical age; and
though his subsequent encomium upon it be somewhat extravagant,
and his reprobation of the man who "is not moved with concord of
sweet sounds," undeservedly harsh and severe, yet are they both
more applicable and judicious than the flippant and undiscriminating
censure of Mr. Steevens, whose note on the subject has met with its
due castigation from the pen of Mr. Douce, who, after stigmatising
the commentator's disingenuous effort to throw an odium on this
recreation, in conjunction with the feeble aid of an illiberal passage
from Lord Chesterfield's Letters, justly and beautifully adds, that "It
is a science which, from its intimate and natural connexion with
poetry and painting, deserves the highest attention and respect. He
that is happily qualified to appreciate the better parts of music, will
never seek them in the society so emphatically reprobated by the
noble lord, nor altogether in the way he recommends. He will not
lend an ear to the vulgarity and tumultuous roar of the tavern catch,
or the delusive sounds of martial clangour; but he will enjoy this
heavenly gift, this exquisite and soul-delighting sensation, in the
temples of his God, or in the peaceful circles of domestic happiness:
he will pursue the blessings and advantages of it with ardour, and
turn aside from its abuses."[391:A]
The fifth act of this play, which consists of but one scene, appears
to have been intended by the poet to remove the painful impressions
incident to the nature of his previous plot; it is light, elegant, and
beautifully written, and, though the main business of the drama
finishes with the termination of the fourth act, it is not felt as an
incumbrance, but on the contrary is beheld and enjoyed as a
graceful, animated, and consolatory close to one of the most perfect
productions of its author.
15. Hamlet: 1597. That this tragedy had been performed before
1598 is evident from Gabriel Harvey's note in Speght's edition of
Chaucer, as quoted by Mr. Malone[391:B]; and, from the intimations
of time brought forward by Mr. Chalmers[391:C], we are induced to
adopt the era of this gentleman, placing the first sketch of Hamlet
early in 1597, and its revision with additions in 1600.[391:D] Soon
after which, namely, on the 26th of July, 1602, it was entered on the
Stationers' book, the first edition hitherto discovered being printed in
the year 1604.
No character in our author's plays has occasioned so much
discussion, so much contradictory opinion, and, consequently, so
much perplexity, as that of Hamlet. Yet we think it may be proved
that Shakspeare had a clear and definite idea of it throughout all its
seeming inconsistencies, and that a very few lines taken from one of
the monologues of this tragedy, will develope the ruling and efficient
feature which the poet held steadily in his view, and through whose
unintermitting influence every other part of the portrait has received
a peculiar modification. We are told, as the result of a deep but
unsatisfactory meditation on the mysteries of another world, on "the
dread of something after death," that

—— "thus the native hue of resolution


Is sicklied o'er with the pale cast of thought;
And enterprises of great pith and moment,
With this regard, their currents turn awry,
And lose the name of action."[392:A]

Now this pale cast of thought and its consequences, which, had
not Hamlet been interrupted by the entrance of Ophelia, he would
have himself applied to his own singular situation, form the very
essence, and give rise to the prominent defects of his character. It is
evident, therefore, that Shakspeare intended to represent him as
variable and indecisive in action, and that he has founded this want
of volition on one of those peculiar constitutions of the mental and
moral faculties which have been designated by the appellation of
genius, a combination of passions and associations which has led to
all the useful energies, and all the exalted eccentricities of human
life; and of which, in one of its most exquisite but speculative forms,
Hamlet presents us with perhaps the only instance on theatric
record.
To a frame of mind naturally strong and contemplative, but
rendered by extraordinary events sceptical and intensely thoughtful,
he unites an undeviating love of rectitude, a disposition of the
gentlest kind, feelings the most delicate and pure, and a sensibility
painfully alive to the smallest deviation from virtue or propriety of
conduct. Thus, while gifted to discern and to suffer from every moral
aberration in those who surround him, his powers of action are
paralysed in the first instance, by the unconquerable tendency of his
mind to explore, to their utmost ramification, all the bearings and
contingencies of the meditated deed; and in the second, by that
tenderness of his nature which leads him to shrink from the means
which are necessary to carry it into execution. Over this irresolution
and weakness, the result, in a great measure, of emotions highly
amiable, and which in a more congenial situation had contributed to
the delight of all who approached him, Shakspeare has thrown a veil
of melancholy so sublime and intellectual, as by this means to
constitute him as much the idol of the philosopher, and the man of
cultivated taste, as he confessedly is of those who feel their interest
excited principally through the medium of the sympathy and
compassion which his ineffective struggles to act up to his own
approved purpose naturally call forth.
It may be useful, however, in order to give more strength and
precision to this general outline, to enter into a few of the leading
particulars of Hamlet's conduct. He is represented at the opening of
the play as highly distressed by the sudden death of his father, and
the hurried and indecent nuptials of his mother, when the awful
appearance of the spectre overwhelms him with astonishment,
unhinges a mind already partially thrown off its bias, and fills it with
indelible apprehension, suspicion, and dismay. For though, on the
first communication of the murder, his bosom burns with the thirst of
vengeance, yet reflection and the gentleness of his disposition soon
induce him to regret that he has been chosen as the instrument of
effecting it,

"That ever he was born to set it right;"

and then, under the influence of this reluctance, he begins to


question the validity and the lawfulness of the medium through
which he had received his information, describing with admirable
self-consciousness, the vacillation of his will, and the tendency of his
temper:—

"The spirit that I have seen


May be the Devil, and the Devil hath power
T' assume a pleasing shape; yea, and perhaps,
Out of my weakness and my melancholy,—
Abuses me to damn me."[394:A]

Here, therefore, on a structure of mind originally indecisive as to


volition, on feelings rendered more than usually sensitive and serious
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookmass.com

You might also like