From 11ff8190b1e247c399178b4b1ebe49b72e27b299 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 21:15:12 +0100 Subject: [PATCH] add documentation for format --- docs/commands/format.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 docs/commands/format.md diff --git a/docs/commands/format.md b/docs/commands/format.md new file mode 100644 index 000000000..836f25b98 --- /dev/null +++ b/docs/commands/format.md @@ -0,0 +1,37 @@ +# format + +Format columns into a string using a simple pattern + +Syntax: `format ` + +### Parameters + +* ``: the pattern to match + +## Example + +Let's say we have a table like this: + +```shell +> open pets.csv +━━━┯━━━━━━━━━━━┯━━━━━━━━┯━━━━━ + # │ animal │ name │ age +───┼───────────┼────────┼───── + 0 │ cat │ Tom │ 7 + 1 │ dog │ Alfred │ 10 + 2 │ chameleon │ Linda │ 1 +━━━┷━━━━━━━━━━━┷━━━━━━━━┷━━━━━ +``` + +`format` allows us to convert table data into a string by following a formatting pattern. To print the value of a column we have to put the column name in curly brackets: + +```shell +> open pets.csv | format "{name} is a {age} year old {animal}" +━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ +───┼───────────────────────────────── + 0 │ Tom is a 7 year old cat + 1 │ Alfred is a 10 year old dog + 2 │ Linda is a 1 year old chameleon +━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file