Skip to main content

Following along

Send commands to tmux or to a terminal in the reader

s sends the commands of the block at the cursor to a terminal, so you can follow along without copying and pasting. S also runs them. On a line outside a code block, both show labels to pick a block.

Where they go depends on where you are:

tomes
tomes https://dsatcl.jeroenjanssens.com/ -c 5
tomes
 Data Science at the Command Li… │                                                                           ┃
 Welcome                         │ 5  Scrubbing Data                                                         │
 Foreword                        │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  │
 Preface                         │                                                                           │
 1  Introduction                 │ Two chapters ago, in the first step of the OSEMN model for data science,  │
 2  Getting Started              │ we looked at obtaining data from a variety of sources. This chapter is    │
 3  Obtaining Data               │ all about the second step: scrubbing data. You see, it’s quite rare that  │
 4  Creating Command-line Tools  │ you can immediately continue with exploring or even modeling the data.    │
▸5  Scrubbing Data               │ There’s a plethora of reasons why your data first needs some cleaning,    │
   5.1 Overview                  │ or scrubbing.                                                             │
   5.2 Transformations, Transf…  │                                                                           │
   5.3 Plain Text                │ For starters, the data might not be in the desired format. For example,   │
     5.3.1 Filtering Lines       │ you may have obtained some JSON data from an API, but you need it to be   │
     5.3.2 Extracting Values     │ in CSV format to create a visualization. Other common formats include     │
     5.3.3 Replacing and Delet…  │ plain text, HTML, and XML. Most command-line tools only work with one or  │
   5.4 CSV                       │ two formats, so it’s important that you’re able to convert data from one  │
     5.4.1 Bodies and Headers …  │ format to another.                                                        │
     5.4.2 Performing SQL Quer…  │                                                                           │
     5.4.3 Extracting and Reor…  │ Once the data is in the desired format, there could still be issues like  │
     5.4.4 Filtering Rows        │ missing values, inconsistencies, weird characters, or unnecessary parts.  │
     5.4.5 Merging Columns       │ You can fix these by applying filters, replacing values, and combining    │
     5.4.6 Combining Multiple …  │ multiple files. The command line is especially well-suited for these      │
   5.5 Working with XML/HTML a…  │ kind of transformations, because there are many specialized tools         │
   5.6 Summary                   │ available, most of which can handle large amounts of data. In this        │
   5.7 For Further Exploration   │ chapter I’ll discuss classic tools such as grep¹ and awk², and newer      │
 6  Project Management with Ma…  │ tools such as jq³ and pup⁴.                                               │
 7  Exploring Data               │                                                                           │
 8  Parallel Pipelines           │ Sometimes you can use the same command-line tool to perform several       │
 9  Modeling Data                │ operations or multiple tools to perform the same operation. This chapter  │
 5  Scrubbing Data                                                                ▶ terminal  term  8/16  Top 
tomes
 Data Science at the Command Li… │                                                                           ┃
 Welcome                         │ This chapter starts with the following files:                             │
 Foreword                        │                                                                           │
 Preface                         │                                                         ⧉ copy  ▶ send    │
 1  Introduction                 │  $ cd /data/ch05                                                          │
 2  Getting Started              │                                                                           │
 3  Obtaining Data               │  $ l                                                                      │
 4  Creating Command-line Tools  │  total 200K                                                               │
 5  Scrubbing Data               │  -rw-r--r-- 1 dst dst 164K Nov 26 11:54 alice.txt                         │
▸  5.1 Overview                  │  -rw-r--r-- 1 dst dst 4.5K Nov 26 11:54 iris.csv                          │
   5.2 Transformations, Transf…  │  -rw-r--r-- 1 dst dst  179 Nov 26 11:54 irismeta.csv                      │
   5.3 Plain Text                │  -rw-r--r-- 1 dst dst  160 Nov 26 11:54 names-comma.csv                   │
     5.3.1 Filtering Lines       │  -rw-r--r-- 1 dst dst  129 Nov 26 11:54 names.csv                         │
     5.3.2 Extracting Values     │  -rw-r--r-- 1 dst dst 7.8K Nov 26 11:54 tips.csv                          │
     5.3.3 Replacing and Delet…  │  -rw-r--r-- 1 dst dst 5.1K Nov 26 11:54 users.json                        │
   5.4 CSV                       │                                                                           │
     5.4.1 Bodies and Headers …  │                                                                           │
     5.4.2 Performing SQL Quer…  │╭ /opt/homebrew/bin/bash · Ctrl-w w: type here ────────────────────────────╮
     5.4.3 Extracting and Reor…  ││$                                                                         │
     5.4.4 Filtering Rows        ││                                                                          │
     5.4.5 Merging Columns       ││                                                                          │
     5.4.6 Combining Multiple …  ││                                                                          │
   5.5 Working with XML/HTML a…  ││                                                                          │
   5.6 Summary                   ││                                                                          │
   5.7 For Further Exploration   ││                                                                          │
 6  Project Management with Ma…  ││                                                                          │
 7  Exploring Data               ││                                                                          │
 8  Parallel Pipelines           ││                                                                          │
 9  Modeling Data                │╰──────────────────────────────────────────────────────────────────────────╯
 Terminal opened (Ctrl-w w switches to it)                                         ▶ terminal  term  8/16  3% 
tomes
 Data Science at the Command Li… │                                                                           ┃
 Welcome                         │ This chapter starts with the following files:                             │
 Foreword                        │                                                                           │
 Preface                         │                                                         ⧉ copy  ▶ send    │
 1  Introduction                 │  $ cd /data/ch05                                                          │
 2  Getting Started              │                                                                           │
 3  Obtaining Data               │  $ l                                                                      │
 4  Creating Command-line Tools  │  total 200K                                                               │
 5  Scrubbing Data               │  -rw-r--r-- 1 dst dst 164K Nov 26 11:54 alice.txt                         │
▸  5.1 Overview                  │  -rw-r--r-- 1 dst dst 4.5K Nov 26 11:54 iris.csv                          │
   5.2 Transformations, Transf…  │  -rw-r--r-- 1 dst dst  179 Nov 26 11:54 irismeta.csv                      │
   5.3 Plain Text                │  -rw-r--r-- 1 dst dst  160 Nov 26 11:54 names-comma.csv                   │
     5.3.1 Filtering Lines       │  -rw-r--r-- 1 dst dst  129 Nov 26 11:54 names.csv                         │
     5.3.2 Extracting Values     │  -rw-r--r-- 1 dst dst 7.8K Nov 26 11:54 tips.csv                          │
     5.3.3 Replacing and Delet…  │  -rw-r--r-- 1 dst dst 5.1K Nov 26 11:54 users.json                        │
   5.4 CSV                       │                                                                           │
     5.4.1 Bodies and Headers …  │                                                                           │
     5.4.2 Performing SQL Quer…  │╭ /opt/homebrew/bin/bash · Ctrl-w w: type here ────────────────────────────╮
     5.4.3 Extracting and Reor…  ││$ cd /data/ch05                                                           │
     5.4.4 Filtering Rows        ││l                                                                         │
     5.4.5 Merging Columns       ││                                                                          │
     5.4.6 Combining Multiple …  ││                                                                          │
   5.5 Working with XML/HTML a…  ││                                                                          │
   5.6 Summary                   ││                                                                          │
   5.7 For Further Exploration   ││                                                                          │
 6  Project Management with Ma…  ││                                                                          │
 7  Exploring Data               ││                                                                          │
 8  Parallel Pipelines           ││                                                                          │
 9  Modeling Data                │╰──────────────────────────────────────────────────────────────────────────╯
 Typed it in the terminal (press Enter there to run it)                            ▶ terminal  term  8/16  3% 

Space s chooses where commands go: the last tmux pane, a particular one, the terminal in the reader, or the clipboard. :target tmux (or terminal, clipboard) does the same from the command line.

In the book’s own environment

Some books come with a Docker image that has all their tools, like Data Science at the Command Line. When you read such a book with dsatcl and Docker is installed, the terminal in the reader can run in that image; tomes asks once. Inside the image itself, commands run right there.

The terminal in the reader

Key What
Ctrl-w w Between the book and the terminal
Ctrl-w . Send Ctrl-w to the terminal
Ctrl-w c Close the terminal
Shift-PageUp Scroll back