Home Explore Blog CI



nushell

commands/docs/from_tsv.md
47589acd7a33df9ced11fa9d738debca0cd74906ca4ffc300000000300000c38
---
title: from tsv
categories: |
  formats
version: 0.104.0
formats: |
  Parse text as .tsv and create table.
usage: |
  Parse text as .tsv and create table.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `from tsv` for [formats](/commands/categories/formats.md)

<div class='command-title'>Parse text as .tsv and create table.</div>

## Signature

```> from tsv {flags} ```

## Flags

 -  `--comment, -c {string}`: a comment character to ignore lines starting with it
 -  `--quote, -q {string}`: a quote character to ignore separators in strings, defaults to '"'
 -  `--escape, -e {string}`: an escape character for strings containing the quote character
 -  `--noheaders, -n`: don't treat the first row as column names
 -  `--flexible`: allow the number of fields in records to be variable
 -  `--no-infer`: no field type inferencing
 -  `--trim, -t {string}`: drop leading and trailing whitespaces around headers names and/or field values


## Input/output types:

| input  | output |
| ------ | ------ |
| string | table  |
## Examples

Convert tab-separated data to a table
```nu
> "ColA	ColB
1	2" | from tsv
╭───┬──────┬──────╮
│ # │ ColA │ ColB │
├───┼──────┼──────┤
│ 0 │    1 │    2 │
╰───┴──────┴──────╯

```

Convert comma-separated data to a table, allowing variable number of columns per row and ignoring headers
```nu
> "value 1
value 2	description 2" | from tsv --flexible --noheaders
╭───┬─────────┬───────────────╮
│ # │ column0 │    column1    │
├───┼─────────┼───────────────┤
│ 0 │ value 1 │      ❎       │
│ 1 │ value 2 │ description 2 │
╰───┴─────────┴───────────────╯

```

Create a tsv file with header columns and open it
```nu
> $'c1(char tab)c2(char tab)c3(char nl)1(char tab)2(char tab)3' | save tsv-data | open tsv-data | from tsv

```

Create a tsv file without header columns and open it
```nu
> $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --noheaders

```

Create a tsv file without header columns and open it, removing all unnecessary whitespaces
```nu
> $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim all

```

Create a tsv file without header columns and open it, removing all unnecessary whitespaces in the header names
```nu
> $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim headers

```

Create a tsv file without header columns and open it, removing all unnecessary whitespaces in the field values
```nu
> $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim fields

```

Chunks
392cfb2e (1st chunk of `commands/docs/from_tsv.md`)
Title: from tsv
Summary
The `from tsv` command in Nushell parses tab-separated value (TSV) text into a table. It supports various flags to customize the parsing, such as specifying a comment character, quote character, escape character, handling headers, allowing flexible field counts, disabling type inference, and trimming whitespace. The command takes a string as input and outputs a table.