Chapter 6. Data Loading, Storage, and File Formats
Reading data and making it accessible (often called data loading) is a necessary first step for using most of the tools in this book. The term parsing is also sometimes used to describe loading text data and interpreting it as tables and different data types. I’m going to focus on data input and output using pandas, though there are numerous tools in other libraries to help with reading and writing data in various formats.
Input and output typically fall into a few main categories: reading text files and other more efficient on-disk formats, loading data from databases, and interacting with network sources like web APIs.
6.1 Reading and Writing Data in Text Format
pandas features a number of functions for
reading tabular data as a DataFrame object. Table 6-1 summarizes some of them;
pandas.read_csv
is one of
the most frequently used in this book. We will look at binary
data formats later in Section 6.2, “Binary Data Formats,”.
Function | Description |
---|---|
read_csv | Load delimited data from a file, URL, or file-like object; use comma as default delimiter |
read_fwf | Read data in fixed-width column format (i.e., no delimiters) |
read_clipboard | Variation of read_csv
that reads data from the clipboard; useful for converting tables
from web pages |
read_excel | Read tabular data from an Excel XLS or XLSX file |
read_hdf | Read HDF5 files written by pandas |
read_html | Read all tables found in the given HTML document ... |
Get Python for Data Analysis, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.