From 72fd1b047f63286f494cee027f8be7f660f481e2 Mon Sep 17 00:00:00 2001 From: Paul Delafosse Date: Fri, 25 Oct 2019 19:52:40 +0200 Subject: [PATCH] Create docs for from-csv command Partial fix of issue nushell#711 --- docs/commands/from-csv.md | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 docs/commands/from-csv.md diff --git a/docs/commands/from-csv.md b/docs/commands/from-csv.md new file mode 100644 index 0000000000..86d309d86b --- /dev/null +++ b/docs/commands/from-csv.md @@ -0,0 +1,47 @@ +# from-csv + +Converts csv data into table. Use this when nushell cannot dertermine the input file extension. + +## Example +Let's say we have the following file : +```shell +> cat pets.txt +animal, name, age +cat, Tom, 7 +dog, Alfred, 10 +chameleon, Linda, 1 +``` + +`pets.txt` is actually a .csv file but it has the .txt extension, `open` is not able to convert it into a table : + +```shell +> open pets.txt +animal, name, age +cat, Tom, 7 +dog, Alfred, 10 +chameleon, Linda, 1 +``` + +To get a table from `pets.txt` we need to use the `from-csv` command : + +```shell +> open pets.txt | from-csv +━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━ + # │ animal │ name │ age +───┼───────────┼─────────┼────── + 0 │ cat │ Tom │ 7 + 1 │ dog │ Alfred │ 10 + 2 │ chameleon │ Linda │ 1 +━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━ +``` + +To ignore the csv headers use `--headerless` : +```shell +━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━ + # │ Column1 │ Column2 │ Column3 +───┼───────────┼─────────┼───────── + 0 │ dog │ Alfred │ 10 + 1 │ chameleon │ Linda │ 1 +━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━ +``` +