9 Files and Exceptions

Objectives

In this chapter you’ll:

  • Understand the notions of files and persistent data.

  • Read, write and update files.

  • Read and write CSV files, a common format for machine-learning datasets.

  • Serialize objects into the JSON data-interchange format—commonly used to transmit over the Internet—and deserialize JSON into objects.

  • Use the with statement to ensure that resources are properly released, avoiding “resource leaks.”

  • Use the try statement to delimit code in which exceptions may occur and handle those exceptions with associated except clauses.

  • Use the try statement’s else clause to execute code when no exceptions occur in the try suite.

  • Use the try statement’s finally clause to execute code regardless of whether an exception occurs in the try.

  • raise exceptions to indicate runtime problems.

  • Understand the traceback of functions and methods that led to an exception.

  • Use pandas to load into a DataFrame and process the Titanic Disaster CSV dataset.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.141.6