Home Explore Blog CI



nushell

1st chunk of `lang-guide/chapters/types/basic_types/cellpath.md`
20d8fbdf213bc53a84d02bd5df7c19c5fe3c2d40c1e6ab6d0000000100000893
# Cell-Path

|                               |                                                                                                                                                                                                           |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **_Description:_**            | An expression that is used to navigated to an inner value in a structured value.                                                                                                                          |
| **_Annotation:_**             | `cell-path`                                                                                                                                                                                               |
| **_Literal syntax example:_** | A dot-separated list of row (int) and column (string) IDs. E.g., `name.4.5`. Optionally, use a leading `$.` when needed for disambiguation, such as when assigning a cell-path to a variable (see below). |
| **_Casts:_**                  | [`into cell-path`](/commands/docs/into_cell-path.md)                                                                                                                                                      |
| **_See also:_**               | [Navigating and Accessing Structured Data](/book/navigating_structured_data.md) for an in-depth overview.                                                                                                 |

## Literal Syntax Options

- Relaxed form:

  ```nu
  > $data | get name.5
  ```

- Leading `$.` form:

  When assigning a cell path to a variable, the leading `$.` syntax is required:

  ```nu
  > let cp: cell-path = name.5
  # => Error
  > let cp: cell-path = $.name.5

  This is not required when using cell-path arguments to a custom command.
  ```

## Additional Language Notes

1. Ordering

   - When accessing a cell in a table using a cell-path, either the row index or the column name can be listed first.

Title: Cell-Path in Nushell
Summary
This section describes the `cell-path` type in Nushell, which is used to navigate to inner values within structured data. It details the syntax for cell paths, including relaxed and explicit forms (using `$.`). The leading `$.` is required when assigning a cell path to a variable. It also mentions that when accessing a cell in a table using a cell-path, either the row index or the column name can be listed first.