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

to csv for formats

Convert table into .csv text .

Signature

> to csv {flags}

Flags

  • --separator, -s {string}: a character to separate columns, defaults to ','
  • --noheaders, -n: do not output the columns names as the first row
  • --columns {list<string>}: the names (in order) of the columns to use

Input/output types:

inputoutput
recordstring
tablestring

Examples

Outputs a CSV string representing the contents of this table

> [[foo bar]; [1 2]] | to csv
foo,bar
1,2

Outputs a CSV string representing the contents of this table

> [[foo bar]; [1 2]] | to csv --separator ';'
foo;bar
1;2

Outputs a CSV string representing the contents of this record

> {a: 1 b: 2} | to csv
a,b
1,2

Outputs a CSV stream with column names pre-determined

> [[foo bar baz]; [1 2 3]] | to csv --columns [baz foo]
baz,foo
3,1