From 44647c0736d1245b0f1dd608d902f5399cefe012 Mon Sep 17 00:00:00 2001 From: Harel Ben-Attia Date: Sat, 14 Jun 2014 15:27:04 -0400 Subject: Update EXAMPLES.markdown --- examples/EXAMPLES.markdown | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'examples/EXAMPLES.markdown') diff --git a/examples/EXAMPLES.markdown b/examples/EXAMPLES.markdown index 694144e..b18133c 100644 --- a/examples/EXAMPLES.markdown +++ b/examples/EXAMPLES.markdown @@ -1,22 +1,11 @@ # q - Treating Text as a Database -__Command 1 (Join data from two files):__ - -The following command _joins_ an ls output (`exampledatafile`) and a file containing rows of **group-name,email** (`group-emails-example`) and provides a row of **filename,email** for each of the emails of the group. For brevity of output, there is also a filter for a specific filename called `ppp` which is achieved using a WHERE clause. -```bash -q "select myfiles.c8,emails.c2 from exampledatafile myfiles join group-emails-example emails on (myfiles.c4 = emails.c1) where myfiles.c8 = 'ppp'" -``` - -__Output 1: (rows of filename,email):__ -```bash -ppp dip.1@otherdomain.com -ppp dip.2@otherdomain.com -``` +See below for a JOIN example. -You can see that the ppp filename appears twice, each time matched to one of the emails of the group `dip` to which it belongs. Take a look at the files [`exampledatafile`](exampledatafile) and [`group-emails-example`](group-emails-example) for the data. - ## Tutorial -Let's postpone the official usage (See below). Look at the examples, and you'll get the general idea. +This is a tutorial for beginners. If you're familiar with the concept and just wanna see some full fledged examples, take a look [here](README.markdown#examples) in the main page. + +Tutorial steps: 1. We'll start with a simple example and work from there. The file `exampledatafile` contains the output of an `ls -l` command, a list of files in some directory. In this example we'll do some calculations on this file list. * The following commands will count the lines in the file *exampledatafile*, effectively getting the number of files in the directory. The output will be exactly as if we ran the `wc -l` command. @@ -64,6 +53,23 @@ Let's postpone the official usage (See below). Look at the examples, and you'll * The filename is actually all files matching "datafile*.gz" - Multiple files can be read, and since they have a .gz extension, they are decompressed on the fly. * **NOTE:** For non-SQL people, the date manipulation may seem odd at first, but this is standard SQL processing for timestamps and it's easy to get used to. +## JOIN example + +__Command 1 (Join data from two files):__ + +The following command _joins_ an ls output (`exampledatafile`) and a file containing rows of **group-name,email** (`group-emails-example`) and provides a row of **filename,email** for each of the emails of the group. For brevity of output, there is also a filter for a specific filename called `ppp` which is achieved using a WHERE clause. +```bash +q "select myfiles.c8,emails.c2 from exampledatafile myfiles join group-emails-example emails on (myfiles.c4 = emails.c1) where myfiles.c8 = 'ppp'" +``` + +__Output 1: (rows of filename,email):__ +```bash +ppp dip.1@otherdomain.com +ppp dip.2@otherdomain.com +``` + +You can see that the ppp filename appears twice, each time matched to one of the emails of the group `dip` to which it belongs. Take a look at the files [`exampledatafile`](exampledatafile) and [`group-emails-example`](group-emails-example) for the data. + ## Installation Installation instructions can be found [here](../doc/INSTALL.markdown) -- cgit v1.2.3