Chapter 7Working with Data
The core function of any research laboratory is to run experiments and collect data. In this chapter, we take a deep dive into some of the most important tools available in Python for working with data.
7.1 A File System Primer
Before we get started, let’s review the file system. Recall that a file can be thought of as a stored sequence of bytes. A computer’s file system provides a way to store and organize files permanently on disk. The computer’s operating system includes software that is used to access and modify these files and their content.
Files in a file system are organized as a hierarchy with a single root directory or folder at the top. The terms folder and directory are used interchangeably. We’ll try to stick with the term directory because Python uses that term in several of its commands. A directory can contain files and additional nested subdirectories, forming a multi-level data structure. Each file and directory in a file system is identified uniquely using a path starting at the file system root. A path is the location of the file or directory as found by navigating the file system from the root directory.
For example, let’s assume we have the file hierarchy of Figure 7.1. The root directory of the file system is named "/" and it contains one subdirectory named Documents. The Documents directory contains the Instruments directory, which itself contains the two subdirectories Data and Backup. The Data directory contains the file ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access