mirror of
https://github.com/nushell/nushell.git
synced 2024-12-29 10:29:42 +01:00
72fd1b047f
Partial fix of issue nushell#711
1.5 KiB
1.5 KiB
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 :
> 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 :
> 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 :
> 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
:
━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━
# │ Column1 │ Column2 │ Column3
───┼───────────┼─────────┼─────────
0 │ dog │ Alfred │ 10
1 │ chameleon │ Linda │ 1
━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━