2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: flatten
|
|
|
|
layout: command
|
2022-03-04 13:10:09 +01:00
|
|
|
version: 0.59.1
|
2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
|
2021-05-30 02:57:04 +02:00
|
|
|
Flatten the table.
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Signature
|
|
|
|
|
|
|
|
```> flatten ...rest```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
- `...rest`: optionally flatten data by column
|
2021-05-30 02:57:04 +02:00
|
|
|
|
|
|
|
## Examples
|
2022-02-14 03:22:51 +01:00
|
|
|
|
|
|
|
flatten a table
|
|
|
|
```shell
|
2022-02-22 14:11:46 +01:00
|
|
|
> [[N, u, s, h, e, l, l]] | flatten
|
2022-02-14 03:22:51 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
flatten a table, get the first item
|
|
|
|
```shell
|
|
|
|
> [[N, u, s, h, e, l, l]] | flatten | first
|
|
|
|
```
|
|
|
|
|
|
|
|
flatten a column having a nested table
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [[origin, people]; [Ecuador, ([[name, meal]; ['Andres', 'arepa']])]] | flatten | get meal
|
|
|
|
```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
restrict the flattening by passing column names
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [[origin, crate, versions]; [World, ([[name]; ['nu-cli']]), ['0.21', '0.22']]] | flatten versions | last | get versions
|
|
|
|
```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Flatten inner table
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> { a: b, d: [ 1 2 3 4 ], e: [ 4 3 ] } | flatten
|
|
|
|
```
|