Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

from csv for formats

Parse text as .csv and create table.

Signature

> from csv {flags}

Flags

  • --separator, -s {string}: a character to separate columns (either single char or 4 byte unicode sequence), defaults to ','
  • --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:

inputoutput
stringtable

Examples

Convert comma-separated data to a table

> "ColA,ColB
1,2" | from csv
╭───┬──────┬──────╮
│ # │ ColA │ ColB │
├───┼──────┼──────┤
│ 0 │    1 │    2 │
╰───┴──────┴──────╯

Convert comma-separated data to a table, allowing variable number of columns per row

> "ColA,ColB
1,2
3,4,5
6" | from csv --flexible
╭───┬──────┬──────┬─────────╮
│ # │ ColA │ ColB │ column2 │
├───┼──────┼──────┼─────────┤
│ 0 │    1 │    2 │   ❎    │
│ 1 │    3 │    4 │       5 │
│ 2 │    6 │  ❎  │   ❎    │
╰───┴──────┴──────┴─────────╯

Convert comma-separated data to a table, ignoring headers

> open data.txt | from csv --noheaders

Convert semicolon-separated data to a table

> open data.txt | from csv --separator ';'

Convert comma-separated data to a table, ignoring lines starting with '#'

> open data.txt | from csv --comment '#'

Convert comma-separated data to a table, dropping all possible whitespaces around header names and field values

> open data.txt | from csv --trim all

Convert comma-separated data to a table, dropping all possible whitespaces around header names

> open data.txt | from csv --trim headers

Convert comma-separated data to a table, dropping all possible whitespaces around field values

> open data.txt | from csv --trim fields