Home Explore Blog CI



nushell

6th chunk of `blog/2019-08-23-introducing-nushell.md`
6ae536389ea3765dfb3e2bc5790f166735cbdc88eb7d74410000000100000faf
---+------------------------------
```

Next, we can create our columns by splitting each row at the pipe (`|`) symbol:

```
> open people.psv | lines | split-column "|"
---+----------+-----------+-----------
 # | Column1  | Column2   | Column3
---+----------+-----------+-----------
 0 | Octavia  |  Butler   |  Writer
 1 | Bob      |  Ross     |  Painter
 2 | Antonio  |  Vivaldi  |  Composer
---+----------+-----------+-----------
```

That's already good enough that we can work with the data. We can go a step further and name the columns if we want:

```
> open people.psv | lines | split-column " | " firstname lastname job
---+-----------+----------+----------
 # | firstname | lastname | job
---+-----------+----------+----------
 0 | Octavia   | Butler   | Writer
 1 | Bob       | Ross     | Painter
 2 | Antonio   | Vivaldi  | Composer
---+-----------+----------+----------
```

But what about working with commands outside of Nu? Let's first call the native version of `ls` instead of the Nu version:

```
> ^ls
assets	     Cargo.lock  docs	images	 Makefile.toml	README.md     rustfmt2.toml  src     tests
Cargo2.toml  Cargo.toml  extra	LICENSE  open		readonly.txt  rustfmt.toml   target
```

We'll use the same commands we used on data to bring it into Nu:

```
^ls | split-row " " file
----+---------------
 #  | value
----+---------------
 0  | assets
 1  | Cargo2.toml
 2  | Cargo.lock
 3  | Cargo.toml
 4  | docs
 5  | extra
 6  | images
 7  | LICENSE
 8  | Makefile.toml
 9  | open
 10 | README.md
 11 | readonly.txt
 12 | rustfmt2.toml
 13 | rustfmt.toml
 14 | src
 15 | target
 16 | tests
----+---------------
```

Or maybe we want to work with the native `ls -la`:

```
^ls -la | lines | split-column " "
----+------------+---------+----------+----------+---------+---------+---------+---------+---------------
 #  | Column1    | Column2 | Column3  | Column4  | Column5 | Column6 | Column7 | Column8 | Column9
----+------------+---------+----------+----------+---------+---------+---------+---------+---------------
 0  | total      | 296     |          |          |         |         |         |         |
 1  | drwxr-xr-x | 13      |  sophia  |  sophia  | 4096    | Aug     | 24      | 03:24   | .
 2  | drwxr-xr-x | 21      |  sophia  |  sophia  | 4096    | Aug     | 22      | 17:00   | ..
 3  | drwxr-xr-x | 2       |  sophia  |  sophia  | 4096    | Aug     | 3       | 05:39   | assets
 4  | drwxr-xr-x | 2       |  sophia  |  sophia  | 4096    | Aug     | 21      | 19:29   | .azure
 5  | drwxr-xr-x | 2       |  sophia  |  sophia  | 4096    | Jun     | 23      | 05:09   | .cargo
 6  | -rw-r--r-- | 1       |  sophia  |  sophia  | 2963    | Aug     | 22      | 20:17   | Cargo2.toml
 7  | -rw-r--r-- | 1       |  sophia  |  sophia  | 201255  | Aug     | 24      | 03:24   | Cargo.lock
 8  | -rw-r--r-- | 1       |  sophia  |  sophia  | 3127    | Aug     | 24      | 03:24   | Cargo.toml
 9  | drwxr-xr-x | 2       |  sophia  |  sophia  | 4096    | Jun     | 17      | 15:32   | docs
 10 | -rw-r--r-- | 1       |  sophia  |  sophia  | 148     | Jun     | 17      | 15:32   | .editorconfig
 11 | drwxr-xr-x | 4       |  sophia  |  sophia  | 4096    | Aug     | 22      | 19:29   | extra
 12 | drwxr-xr-x | 8       |  sophia  |  sophia  | 4096    | Aug     | 24      | 03:24   | .git
 13 | -rw-r--r-- | 1       |  sophia  |  sophia  | 58      | Aug     | 10      | 11:08   | .gitignore
 14 | drwxr-xr-x | 2       |  sophia  |  sophia  | 4096    | Aug     | 24      | 03:24   | images
 15 | -rw-r--r-- | 1       |  sophia  |  sophia  | 1085    | Jun     | 17      | 15:32   | LICENSE
 16 | -rw-r--r-- | 1       |  sophia  |  sophia  | 614     | Jun     | 17      | 15:32   | Makefile.toml
 17 | -rw-r--r-- | 1       |  sophia  |  sophia  | 0       | Aug     | 23      | 04:58   | open
 18 | -rw-r--r-- | 1       |  sophia  |  sophia  | 11375   | Aug     | 24      | 03:24   | README.md
 19 | -r--r--r-- | 1       |  sophia  |  sophia  | 0       | Jul     | 4       | 03:51   | readonly.txt

Title: Splitting Rows and Columns: Integrating External Commands
Summary
Nushell uses split-row and split-column to manipulate strings. These commands are used to handle unstructured data and output from external commands. Calling `ls` through Nu and processing the output with `split-row` or `split-column` allows for Nu to access and transform external data.