Rainbow CSV has content-based CSV/TSV autodetection mechanism enabled by default. This means that package will analyze plain text files even if they do not have ".csv" or ".tsv" extension. You can disable content-based autodetection mechanism at the package settings page.
Rainbow highlighting can also be manually enabled from Atom context menu:
You can also disable rainbow highlighting and go back to the original file highlighting using the same context menu.
This feature can be used to temporary rainbow-highlight even non-table files.
Highlighting colors can be adjusted in package settings.
To Run RBQL query select "Rainbow CSV -> RBQL" from Atom context menu or click "RBQL" button at the status panel or run "rbql" command.
By default RBQL uses JavaScript backend, but it can be changed to Python in package settings.
When manually enabling rainbow highlighting from the context menu, you have to choose between "Standard" and "Simple" dialects.
sell,"15,128",23%
will be treated as 3 columns, because the second comma is quoted. This dialect is used by Excel.RBQL is a technology for (not only) CSV files processing. It provides SQL-like language that supports SELECT queries with Python or JavaScript expressions.
RBQL is distributed with CLI apps, text editor plugins, Python and JS libraries and can work in web browsers.
RBQL core module is very generic and can process all kind of objects and record formats, but most popular RBQL implementation works with CSV files.
All keywords have the same meaning as in SQL queries. You can check them online
RBQL for CSV files provides the following variables which you can use in your queries:
select a1, b2 JOIN /path/to/b.csv ON a['Item Id'] == b.Identifier WHERE NR > 1 and int(a.Weight) * 100 > int(b["weight of the item"])
where NR > 1
trick to skip it)UPDATE query produces a new table where original values are replaced according to the UPDATE expression, so it can also be considered a special type of SELECT query. This prevents accidental data loss from poorly written queries.
UPDATE SET is synonym to UPDATE, because in RBQL there is no need to specify the source table.
RBQL supports the following aggregate functions, which can also be used with GROUP BY keyword:
COUNT, _ARRAYAGG, MIN, MAX, SUM, AVG, VARIANCE, MEDIAN
Limitation: aggregate functions inside Python (or JS) expressions are not supported. Although you can use expressions inside aggregate functions.
E.g. MAX(float(a1) / 1000)
- valid; MAX(a1) / 1000
- invalid.
There is a workaround for the limitation above for _ARRAYAGG function which supports an optional parameter - a callback function that can do something with the aggregated array. Example:
select a2, ARRAY_AGG(a1, lambda v: sorted(v)[:5]) group by a2
- Python; select a2, ARRAY_AGG(a1, v => v.sort().slice(0, 5)) group by a2
- JS
Join table B can be referenced either by it's file path or by it's name - an arbitary string which user should provide before executing the JOIN query.
RBQL supports STRICT LEFT JOIN which is like LEFT JOIN, but generates an error if any key in left table "A" doesn't have exactly one matching key in the right table "B".
Limitation: JOIN statements can't contain Python/JS expressions and must have the following form: _<JOIN_KEYWORD> (/path/to/table.tsv | tablename ) ON a... == b... [AND a... == b... [AND ... ]]
SELECT EXCEPT can be used to select everything except specific columns. E.g. to select everything but columns 2 and 4, run: SELECT * EXCEPT a2, a4
Traditional SQL engines do not support this query mode.
UNNEST(list) takes a list/array as an argument and repeats the output record multiple times - one time for each value from the list argument.
Example: SELECT a1, UNNEST(a2.split(';'))
RBQL does not support LIKE operator, instead it provides "like()" function which can be used like this:
SELECT * where like(a1, 'foo%bar')
RBQL supports User Defined Functions
You can define custom functions and/or import libraries in two special files:
~/.rbql_init_source.py
- for Python~/.rbql_init_source.js
- for JavaScriptselect top 100 a1, int(a2) * 10, len(a4) where a1 == "Buy" order by int(a2) desc
select * order by random.random() where NR > 1
- skip header record and random sortselect len(a.vehicle_price) / 10, a2 where NR > 1 and a['Vehicle type'] in ["car", "plane", "boat"] limit 20
- referencing columns by names from header record, skipping the header and using Python's "in" to emulate SQL's "in"update set a3 = 'NPC' where a3.find('Non-playable character') != -1
select NR, *
- enumerate records, NR is 1-basedselect * where re.match(".*ab.*", a1) is not None
- select entries where first column has "ab" patternselect a1, b1, b2 inner join ./countries.txt on a2 == b1 order by a1, a3
- example of join queryselect MAX(a1), MIN(a1) where a.Name != 'John' group by a2, a3
- example of aggregate queryselect top 100 a1, a2 * 10, a4.length where a1 == "Buy" order by parseInt(a2) desc
select * order by Math.random() where NR > 1
- skip header record and random sortselect top 20 a.vehicle_price.length / 10, a2 where NR > 1 and ["car", "plane", "boat"].indexOf(a['Vehicle type']) > -1 limit 20
- referencing columns by names from header record and skipping the headerupdate set a3 = 'NPC' where a3.indexOf('Non-playable character') != -1
select NR, *
- enumerate records, NR is 1-basedselect a1, b1, b2 inner join ./countries.txt on a2 == b1 order by a1, a3
- example of join queryselect MAX(a1), MIN(a1) where a.Name != 'John' group by a2, a3
- example of aggregate queryYou can use the following trick: add ... where NR > 1 ...
to your query
And if you are doing math operation you can modify your query like this, example:
select int(a3) * 1000, a2
-> select int(a3) * 1000 if NR > 1 else a3, a2