{"id":13897199,"url":"https://github.com/mechatroner/atom-rainbow-csv","last_synced_at":"2025-07-17T14:30:25.006Z","repository":{"id":150421421,"uuid":"117055081","full_name":"mechatroner/atom-rainbow-csv","owner":"mechatroner","description":":rainbow: Atom package: Highlight CSV and TSV spreadsheet files in different rainbow colors","archived":true,"fork":false,"pushed_at":"2020-03-30T02:22:50.000Z","size":330,"stargazers_count":16,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-25T03:32:04.748Z","etag":null,"topics":["atom-package","csv","highlighting","tsv"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mechatroner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-11T05:36:21.000Z","updated_at":"2023-11-24T04:20:28.000Z","dependencies_parsed_at":"2023-05-17T22:15:42.179Z","dependency_job_id":null,"html_url":"https://github.com/mechatroner/atom-rainbow-csv","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/mechatroner/atom-rainbow-csv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Fatom-rainbow-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Fatom-rainbow-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Fatom-rainbow-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Fatom-rainbow-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mechatroner","download_url":"https://codeload.github.com/mechatroner/atom-rainbow-csv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Fatom-rainbow-csv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265616499,"owners_count":23798845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atom-package","csv","highlighting","tsv"],"created_at":"2024-08-06T18:03:25.174Z","updated_at":"2025-07-17T14:30:24.999Z","avatar_url":"https://github.com/mechatroner.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"![Rainbow CSV](https://i.imgur.com/EhV2niB.png)\n\n# Rainbow CSV\n\n### Main features\n\n* Highlight columns in *.csv and *.tsv and other table files in different rainbow colors\n* Provide info about the current column in status bar\n* Run queries in SQL-like RBQL language\n\n![screenshot](https://i.imgur.com/zzhST3A.png)\n\n\n### Usage\nRainbow 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.  \n\nRainbow highlighting can also be manually enabled from Atom context menu:  \n1. Select a character that you want to use as a delimiter with mouse. Delimiter can be any ASCII symbol, e.g. semicolon  \n2. Right mouse click: context menu -\u003e Rainbow CSV -\u003e Set as separator ...  \n\nYou can also disable rainbow highlighting and go back to the original file highlighting using the same context menu.  \nThis feature can be used to temporary rainbow-highlight even non-table files.  \n\nHighlighting colors can be adjusted in package settings.  \n\nTo Run RBQL query select \"Rainbow CSV -\u003e RBQL\" from Atom context menu or click \"RBQL\" button at the status panel or run \"rbql\" command.  \nBy default RBQL uses JavaScript backend, but it can be changed to Python in package settings.  \n\n\n#### Difference between \"Standard\" and \"Simple\" dialects\nWhen manually enabling rainbow highlighting from the context menu, you have to choose between \"Standard\" and \"Simple\" dialects.  \n* __Standard dialect__ will treat quoted separator as a single field. E.g. line `sell,\"15,128\",23%` will be treated as 3 columns, because the second comma is quoted. This dialect is used by Excel.\n* __Simple dialect__ doesn't care about double quotes: the number of highlighted fields is always N + 1 where N is the number of separators.\n\n\n# RBQL (Rainbow Query Language) Description\n\nRBQL is a technology for (not only) CSV files processing. It provides SQL-like language that supports SELECT queries with Python or JavaScript expressions.  \nRBQL is distributed with CLI apps, text editor plugins, Python and JS libraries and can work in web browsers.  \nRBQL core module is very generic and can process all kind of objects and record formats, but most popular RBQL implementation works with CSV files.  \n\n[Official Site](https://rbql.org/)\n\n### Main Features\n\n* Use Python or JavaScript expressions inside _SELECT_, _UPDATE_, _WHERE_ and _ORDER BY_ statements\n* Result set of any query immediately becomes a first-class table on it's own\n* Supports input tables with inconsistent number of fields per record\n* Output records appear in the same order as in input unless _ORDER BY_ is provided\n* Each record has a unique NR (record number) identifier\n* Supports all main SQL keywords\n* Supports aggregate functions and GROUP BY queries\n* Provides some new useful query modes which traditional SQL engines do not have\n* Supports both _TOP_ and _LIMIT_ keywords\n* Supports user-defined functions (UDF)\n* Works out of the box, no external dependencies\n\n#### Limitations:\n\n* RBQL doesn't support nested queries, but they can be emulated with consecutive queries\n* Number of tables in all JOIN queries is always 2 (input table and join table), use consecutive queries to join 3 or more tables\n\n### Supported SQL Keywords (Keywords are case insensitive)\n\n* SELECT\n* UPDATE\n* WHERE\n* ORDER BY ... [ DESC | ASC ]\n* [ LEFT | INNER ] JOIN\n* DISTINCT\n* GROUP BY\n* TOP _N_\n* LIMIT _N_\n\nAll keywords have the same meaning as in SQL queries. You can check them [online](https://www.w3schools.com/sql/default.asp)  \n\n\n### RBQL variables\nRBQL for CSV files provides the following variables which you can use in your queries:\n\n* _a1_, _a2_,..., _a{N}_  \n   Variable type: **string**  \n   Description: value of i-th field in the current record in input table  \n* _b1_, _b2_,..., _b{N}_  \n   Variable type: **string**  \n   Description: value of i-th field in the current record in join table B  \n* _NR_  \n   Variable type: **integer**  \n   Description: Record number (1-based)  \n* _NF_  \n   Variable type: **integer**  \n   Description: Number of fields in the current record  \n* _a.name_, _b.Person_age_, ... _a.{Good_alphanumeric_column_name}_  \n   Variable type: **string**  \n   Description: Value of the field referenced by it's \"name\". You can use this notation if the field in the first (header) CSV line has a \"good\" alphanumeric name  \n* _a[\"object id\"]_, _a['9.12341234']_, _b[\"%$ !! 10 20\"]_ ... _a[\"Arbitrary column name!\"]_  \n   Variable type: **string**  \n   Description: Value of the field referenced by it's \"name\". You can use this notation to reference fields by arbitrary values in the first (header) CSV line, even when there is no header at all  \n\n\n#### Notes:\n* You can mix all variable types in a single query, example:\n  ```select a1, b2 JOIN /path/to/b.csv ON a['Item Id'] == b.Identifier WHERE NR \u003e 1 and int(a.Weight) * 100 \u003e int(b[\"weight of the item\"])```\n* Referencing fields by header names does not automatically skip the header line (you can use `where NR \u003e 1` trick to skip it)\n* If you want to use RBQL as a library for your own app you can define your own custom variables and do not have to support the above mentioned CSV-related variables.\n\n\n### UPDATE statement\n\n_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.  \n_UPDATE SET_ is synonym to _UPDATE_, because in RBQL there is no need to specify the source table.  \n\n\n### Aggregate functions and queries\n\nRBQL supports the following aggregate functions, which can also be used with _GROUP BY_ keyword:  \n_COUNT_, _ARRAY_AGG_, _MIN_, _MAX_, _SUM_, _AVG_, _VARIANCE_, _MEDIAN_  \n\nLimitation: aggregate functions inside Python (or JS) expressions are not supported. Although you can use expressions inside aggregate functions.  \nE.g. `MAX(float(a1) / 1000)` - valid; `MAX(a1) / 1000` - invalid.  \nThere is a workaround for the limitation above for _ARRAY_AGG_ function which supports an optional parameter - a callback function that can do something with the aggregated array. Example:  \n`select a2, ARRAY_AGG(a1, lambda v: sorted(v)[:5]) group by a2` - Python; `select a2, ARRAY_AGG(a1, v =\u003e v.sort().slice(0, 5)) group by a2` - JS\n\n\n### JOIN statements\n\nJoin 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.  \nRBQL 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\".  \nLimitation: _JOIN_ statements can't contain Python/JS expressions and must have the following form: _\u003cJOIN\\_KEYWORD\u003e (/path/to/table.tsv | table_name ) ON a... == b... [AND a... == b... [AND ... ]]_\n\n\n### SELECT EXCEPT statement\n\nSELECT 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`  \nTraditional SQL engines do not support this query mode.\n\n\n### UNNEST() operator\nUNNEST(list) takes a list/array as an argument and repeats the output record multiple times - one time for each value from the list argument.  \nExample: `SELECT a1, UNNEST(a2.split(';'))`  \n\n\n### LIKE() function\nRBQL does not support LIKE operator, instead it provides \"like()\" function which can be used like this:\n`SELECT * where like(a1, 'foo%bar')`\n\n\n### User Defined Functions (UDF)\n\nRBQL supports User Defined Functions  \nYou can define custom functions and/or import libraries in two special files:  \n* `~/.rbql_init_source.py` - for Python\n* `~/.rbql_init_source.js` - for JavaScript\n\n\n## Examples of RBQL queries\n\n#### With Python expressions\n\n* `select top 100 a1, int(a2) * 10, len(a4) where a1 == \"Buy\" order by int(a2) desc`\n* `select * order by random.random() where NR \u003e 1` - skip header record and random sort\n* `select len(a.vehicle_price) / 10, a2 where NR \u003e 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\"\n* `update set a3 = 'NPC' where a3.find('Non-playable character') != -1`\n* `select NR, *` - enumerate records, NR is 1-based\n* `select * where re.match(\".*ab.*\", a1) is not None` - select entries where first column has \"ab\" pattern\n* `select a1, b1, b2 inner join ./countries.txt on a2 == b1 order by a1, a3` - example of join query\n* `select MAX(a1), MIN(a1) where a.Name != 'John' group by a2, a3` - example of aggregate query\n\n#### With JavaScript expressions\n\n* `select top 100 a1, a2 * 10, a4.length where a1 == \"Buy\" order by parseInt(a2) desc`\n* `select * order by Math.random() where NR \u003e 1` - skip header record and random sort\n* `select top 20 a.vehicle_price.length / 10, a2 where NR \u003e 1 and [\"car\", \"plane\", \"boat\"].indexOf(a['Vehicle type']) \u003e -1 limit 20` - referencing columns by names from header record and skipping the header\n* `update set a3 = 'NPC' where a3.indexOf('Non-playable character') != -1`\n* `select NR, *` - enumerate records, NR is 1-based\n* `select a1, b1, b2 inner join ./countries.txt on a2 == b1 order by a1, a3` - example of join query\n* `select MAX(a1), MIN(a1) where a.Name != 'John' group by a2, a3` - example of aggregate query\n\n\n### FAQ\n\n#### How do I skip header record in CSV files?\n\nYou can use the following trick: add `... where NR \u003e 1 ...` to your query  \n\nAnd if you are doing math operation you can modify your query like this, example:  \n`select int(a3) * 1000, a2` -\u003e `select int(a3) * 1000 if NR \u003e 1 else a3, a2`  \n\n\n## References\n\n* rainbow_csv plugin in [Vim](https://github.com/mechatroner/rainbow_csv)\n* Rainbow CSV extension in [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=mechatroner.rainbow-csv)\n* rainbow_csv plugin in [Sublime Text](https://packagecontrol.io/packages/rainbow_csv)\n* rainbow_csv plugin in [gedit](https://github.com/mechatroner/gtk_gedit_rainbow_csv) - doesn't support quoted commas in csv\n* rainbow_csv_4_nedit in [NEdit](https://github.com/DmitTrix/rainbow_csv_4_nedit)\n* CSV highlighting in [Nano](https://github.com/scopatz/nanorc)\n* Rainbow CSV in [IntelliJ IDEA](https://plugins.jetbrains.com/plugin/12896-rainbow-csv/)\n* RBQL [Official Site](https://rbql.org/) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechatroner%2Fatom-rainbow-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmechatroner%2Fatom-rainbow-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechatroner%2Fatom-rainbow-csv/lists"}