From 5635b8378df40c9b05f2c72597b2926a459cf4b9 Mon Sep 17 00:00:00 2001 From: sdfnz <30536578+sdfnz@users.noreply.github.com> Date: Tue, 15 Oct 2019 14:23:32 -0500 Subject: [PATCH] Added documentation for the sum command --- docs/commands/sum.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docs/commands/sum.md diff --git a/docs/commands/sum.md b/docs/commands/sum.md new file mode 100644 index 000000000..f5c59848d --- /dev/null +++ b/docs/commands/sum.md @@ -0,0 +1,35 @@ +# sum + +This command allows you to calculate the sum of values in a column. + +## Examples + +To get the sum of the file sizes in a directory, simply pipe the size column from the ls command to the sum command. + +```shell +> ls | get size | sum +━━━━━━━━━ + value +━━━━━━━━━ + 51.0 MB +━━━━━━━━━ +``` + +Note that sum only works for integer and byte values at the moment, and if the shell doesn't recognize the values in a column as one of those types, it will return an error. + +```shell +> open example.csv +━━━┯━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━ + # │ fruit │ amount │ quality +───┼─────────┼────────┼────────── + 0 │ apples │ 1 │ fresh + 1 │ bananas │ 2 │ old + 2 │ oranges │ 7 │ fresh + 3 │ kiwis │ 25 │ rotten +━━━┷━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━ +``` + +```shell +> open example.csv | get amount | sum +error: Unrecognized type in stream: Primitive(String("1")) +```