W3cubDocs

/Nushell

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:

input output
string table

Examples

Convert comma-separated data to a table

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

Convert comma-separated data to a table, ignoring headers

>opendata.txt|from csv--noheaders

Convert semicolon-separated data to a table

>opendata.txt|from csv--separator';'

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

>opendata.txt|from csv--comment'#'

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

>opendata.txt|from csv--trimall

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

>opendata.txt|from csv--trimheaders

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

>opendata.txt|from csv--trimfields

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/from_csv.html