{"id":13460084,"url":"https://github.com/mechatroner/rainbow_csv","last_synced_at":"2025-12-29T22:33:54.426Z","repository":{"id":5732416,"uuid":"53295528","full_name":"mechatroner/rainbow_csv","owner":"mechatroner","description":"🌈Rainbow CSV - Vim plugin: Highlight columns in CSV and TSV files and run queries in SQL-like language","archived":false,"fork":false,"pushed_at":"2024-04-24T01:35:10.000Z","size":2133,"stargazers_count":573,"open_issues_count":14,"forks_count":18,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-28T01:21:34.577Z","etag":null,"topics":["csv","sql","sql-like","syntax-highlighting","tsv","vim-plugins"],"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":"2016-03-07T04:20:50.000Z","updated_at":"2024-06-01T05:43:56.534Z","dependencies_parsed_at":"2024-01-24T06:07:03.529Z","dependency_job_id":"94d19905-4476-48db-b7cb-e9f6786b364a","html_url":"https://github.com/mechatroner/rainbow_csv","commit_stats":{"total_commits":636,"total_committers":7,"mean_commits":90.85714285714286,"dds":"0.029874213836478036","last_synced_commit":"7453a3f9679f0c753ec9d77f9ea8588778f35aeb"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Frainbow_csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Frainbow_csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Frainbow_csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechatroner%2Frainbow_csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mechatroner","download_url":"https://codeload.github.com/mechatroner/rainbow_csv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222004137,"owners_count":16914872,"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":["csv","sql","sql-like","syntax-highlighting","tsv","vim-plugins"],"created_at":"2024-07-31T10:00:35.274Z","updated_at":"2025-12-29T22:33:54.393Z","avatar_url":"https://github.com/mechatroner.png","language":"Python","readme":"# Rainbow CSV\n\n![rainbow_csv](https://i.imgur.com/EhV2niB.png)\n\n## Installation\nUse your favorite package manager.  \n\nVundle: `Plugin 'mechatroner/rainbow_csv'`  \nVimPlug: `Plug 'mechatroner/rainbow_csv'`  \ndein: `call dein#add('mechatroner/rainbow_csv')`  \n\nNo additional steps required - Rainbow CSV will work out of the box.  \n\n## Overview\nMain features:  \n* Highlight CSV columns in different rainbow colors. \n* Provide info about column under the cursor\n* Provide `SELECT` and `UPDATE` queries in RBQL: SQL-like transprogramming query language.\n* Consistency check for csv files (CSVLint)\n* Align and Shrink CSV fields (add/remove trailing spaces in fields)\n* Cell-level cursor navigation\n\nThere are 4 ways to enable csv columns highlighting:\n1. CSV autodetection based on file content and/or extension  \n2. Manual CSV delimiter selection with `:RainbowDelim` command with cursor over the delimiter  \n3. Manual CSV delimiter selection with `:RainbowMultiDelim` for multi-character delimiters selecting them in \"VISUAL\" mode  \n4. Explicitly activate one of the built-in filetypes, e.g. `:set ft=csv`  \n\nThe core functionality of the plugin is written in pure vimscript, no additional libraries required.  \n\n![Rainbow CSV Screenshot](https://user-images.githubusercontent.com/5349737/190057249-8ec401f6-b76d-4420-a6af-053dd502f8a9.png)\n\n# Plugin description\n\n### Built-in and autogenerated filetypes\nRainbow CSV has 7 built-in CSV filetypes and infinite number of autogenerated filetypes.  \nEach Rainbow CSV filetype is mapped to a separator and \"policy\" which describes additional properties e.g. if separator can be escaped inside double quoted field.  \nIf you run `:RainbowDelim` or `:RainbowMultiDelim` to select a separator that doesn't map to one of the built-in filetypes, Rainbow CSV will dynamically generate the filetype syntax file and put it into the \"syntax\" folder.  \nList of built-in filetypes:  \n\n|Filetype       | Separator     | Extension | Properties                                          |\n|---------------|---------------|-----------|-----------------------------------------------------|\n|csv            | , (comma)     | .csv      | Ignored inside double-quoted fields                 |\n|tsv            | \\t (TAB)      | .tsv .tab |                                                     |\n|csv_semicolon  | ; (semicolon) |           | Ignored inside double-quoted fields                 |\n|csv_whitespace | whitespace    |           | Consecutive whitespaces are merged                  |\n|csv_pipe       | \u0026#124; (pipe) |           |                                                     |\n|rfc_csv        | , (comma)     |           | Same as \"csv\" but allows multiline fields           |\n|rfc_semicolon  | ; (semicolon) |           | Same as \"csv_semicolon\" but allows multiline fields |\n\n\n### Associating file extensions with CSV dialects\nIn most cases the built-in autodetection algorithm should correctly detect correct CSV dialect for all CSV tables that you open in Vim, but if you have disabled the autodetection algorithm or don't want to rely on it for some reason, you can manually associate file extensions with available csv dialects.  \nExample: to associate \".dat\" extension with \"csv_pipe\" dialect and \".csv\" extension with \"csv_semicolon\" add the folowing lines to your .vimrc:  \n```\nautocmd BufNewFile,BufRead *.csv   set filetype=csv_semicolon\nautocmd BufNewFile,BufRead *.dat   set filetype=csv_pipe\n```\n\n### Working with multiline CSV fields\nIn rare cases some CSV files can contain double-quoted fields spanning multiple lines.  \nTo work with such files you can set filetype to either \"rfc_csv\" or \"rfc_semicolon\" e.g. `:set ft=rfc_csv`.  \nSyntax highlighting for rfc_csv and rfc_semicolon dialects can sometimes go out of sync with the file content, use `:syntax sync fromstart` command in that case.  \nrfc_csv and rfc_semicolon are fully supported by RBQL which among other things allows you to easily convert them to line-by-line CSV by replacing newlines in fields with sequences of 4 spaces or something like that.  \nrfc_csv and rfc_semicolon take their name from [RFC 4180](https://tools.ietf.org/html/rfc4180) memo with which they are fully compatible.  \n\n\n### Built-in RBQL query language\nRainbow CSV comes with built-in lightweight RBQL SQL-like query engine.  \nTo run an RBQL query either use `:Select` command  e.g. `:Select a1, a2` or run `:RainbowQuery` command to enter query editing mode.  \n\nDemonstration of rainbow_csv highlighting and RBQL queries \n\n\n![demo_screencast](https://i.imgur.com/4PIVvjc.gif)\n\n\nIn this demo python expressions were used, but JavaScript is also available.\n\n\n### Rainbow highlighting for non-table files\nYou can use rainbow highlighting and RBQL even for non-csv/tsv files.  \nE.g. you can highlight records in log files, one-line xmls and other delimited records.  \nYou can even highlight function arguments in your programming language using comma or comma+whitespaces as a delimiter for `:RainbowDelim` or `:RainbowMultiDelim` commands.  \nAnd you can always turn off the rainbow highlighting using `:NoRainbowDelim` command.  \n\n\n### Commands\n\n#### :RainbowDelim\n\nMark current file as a table and highlight it's columns in rainbow colors. Character under the cursor will be used as a delimiter. The delimiter will be saved in a config file for future vim sessions.\n\nYou can also use this command for non-csv files, e.g. to highlight function arguments  \nin source code in different colors. To return back to original syntax highlighting run `:NoRainbowDelim`\n\n#### :RainbowMultiDelim\n\nSame as `:RainbowDelim`, but works with multicharacter separators.  \nVisually select the multicharacter separator (e.g. `~#~`) and run `:RainbowMultiDelim` command.\n\n#### :NoRainbowDelim\n\nDisable rainbow columns highlighting for the current file.\n\n#### :RainbowCellGoUp\n\nMove cursor one cell up.  \nConsider mapping this to Ctrl+[Up Arrow], see the \"Key Mappings\" section.\n\n#### :RainbowCellGoDown\n\nMove cursor one cell down.  \nConsider mapping this to Ctrl+[Down Arrow], see the \"Key Mappings\" section.\n\n#### :RainbowCellGoLeft\n\nMove cursor one cell left.  \nConsider mapping this to Ctrl+[Left Arrow], see the \"Key Mappings\" section.\n\n#### :RainbowCellGoRight\n\nMove cursor one cell right.  \nConsider mapping this to Ctrl+[Right Arrow], see the \"Key Mappings\" section.\n\n\n#### :RainbowComment\nMark the character under the cursor as the comment prefix, e.g. `#`. By default Rainbow CSV doesn't highlight comments in CSV files.  \nYou can also use `:RainbowCommentMulti` to mark a visual selection as a multicharacter comment prefix  \n\n\n#### :NoRainbowComment\nDisable all comments for the current CSV file.  \nThis command is especially useful when you have set `g:rainbow_comment_prefix` variable and want to exclude just one particular file.  \n\n\n#### :CSVLint\n\nThe linter checks the following:  \n* consistency of double quotes usage in CSV rows  \n* consistency of number of fields per CSV row  \n\n#### :RainbowAlign\n\nAlign CSV columns with whitespaces.  \nDon't run this command if you treat leading and trailing whitespaces in fields as part of the data.  \nYou can edit aligned CSV file in Vim column-edit mode (Ctrl+v).  \n\n#### :RainbowShrink\n\nRemove leading and trailing whitespaces from all fields. Opposite to RainbowAlign\n\n#### :Select ...\n\nAllows to enter RBQL select query as vim command.  \nE.g. `:Select a1, a2 order by a1`\n\n#### :Update ...\n\nAllows to enter RBQL update query as vim command.  \nE.g. `:Update a1 = a1 + \" \" + a2`\n\n#### :RainbowQuery\n\nEnter RBQL Query editing mode.  \nWhen in the query editing mode, execute `:RainbowQuery` again to run the query.  \nConsider mapping `:RainbowQuery` to `\u003cF5\u003e` key i.e. `nnoremap \u003cF5\u003e :RainbowQuery\u003cCR\u003e`\n\n\n#### :RainbowName \\\u003cname\\\u003e\n\nAssign any name to the current table. You can use this name in join operation instead of the table path. E.g.\n```\nJOIN customers ON a1 == b1\n``` \nintead of:\n```\nJOIN /path/to/my/customers/table ON a1 == b1\n```\n\n#### :RainbowCopyBack\n\nThis command only applicable for RBQL output files.  \nReplace the content of the original file that was used to run the RBQL query with the query result set data.\n\n\n### Key Mappings\nPlugin does not create any new key mappings, but you can define your own in your .vimrc file.  \nAll highlighted files have a special buffer variable `b:rbcsv` set to 1, so you can use this to define conditional csv-only key mappings.  \nFor example, to conditionally map Ctrl+Arrow keys to cell navigation commands you can use this snippet:\n\n```\nnnoremap \u003cexpr\u003e \u003cC-Left\u003e get(b:, 'rbcsv', 0) == 1 ? ':RainbowCellGoLeft\u003cCR\u003e' : '\u003cC-Left\u003e'\nnnoremap \u003cexpr\u003e \u003cC-Right\u003e get(b:, 'rbcsv', 0) == 1 ? ':RainbowCellGoRight\u003cCR\u003e' : '\u003cC-Right\u003e'\nnnoremap \u003cexpr\u003e \u003cC-Up\u003e get(b:, 'rbcsv', 0) == 1 ? ':RainbowCellGoUp\u003cCR\u003e' : '\u003cC-Up\u003e'\nnnoremap \u003cexpr\u003e \u003cC-Down\u003e get(b:, 'rbcsv', 0) == 1 ? ':RainbowCellGoDown\u003cCR\u003e' : '\u003cC-Down\u003e'\n```\n\nYou can also map arrow keys unconditionally, but this will have no effect outside highlighted CSV files, e.g.\n```\nnnoremap \u003cC-Right\u003e :RainbowCellGoRight\u003cCR\u003e\n```\n\n### Configuration\n\n#### g:disable_rainbow_hover\nSet to `1` to stop showing info about the column under the cursor in Vim command line  \nExample:  \n```\nlet g:disable_rainbow_hover = 1\n```\n\n#### g:rcsv_delimiters\nDefault: `[\"\\t\", \",\", \";\", \"|\"]`  \nList of separators to try for content-based autodetection  \nYou can add or remove values from the list. Example:\n```\nlet g:rcsv_delimiters = [\"\\t\", \",\", \"^\", \"~#~\"]\n```\n\n#### g:disable_rainbow_csv_autodetect\nSet to `1` to disable CSV autodetection mechanism  \nExample:  \n```\nlet g:disable_rainbow_csv_autodetect = 1\n```\nManual delimiter selection would still be possible. \nYou can also manually associate specific file extensions with 'csv' or 'tsv' filetypes  \n\n#### g:rainbow_comment_prefix\nDefault: `''`  \nA string to use as a comment prefix for all CSV files you open in Vim.  \nThis setting is helpful if you are dealing with lots of CSV files which consistently use the same comment prefix e.g. `'#'` or `'\u003e\u003e'`  \nIf you want to enable comments on file-by-file basis, use the `:RainbowComment` or `:RainbowCommentMulti` commands instead.  \nTo cancel the effect of `g:rainbow_comment_prefix` just for the current file use `:NoRainbowComment` command.  \n\n\n#### g:rcsv_max_columns\nDefault: `30`  \nAutodetection will fail if buffer has more than _g:rcsv\\_max\\_columns_ columns.  \nYou can increase or decrease this limit.\n\n#### g:rcsv_colorpairs\nList of color name pairs to customize rainbow highlighting.  \nEach entry in the list is a pair of two colors: the first color is for terminal mode, the second one is for GUI mode.  \nExample:\n```\nlet g:rcsv_colorpairs = [['red', 'red'], ['blue', 'blue'], ['green', 'green'], ['magenta', 'magenta'], ['NONE', 'NONE'], ['darkred', 'darkred'], ['darkblue', 'darkblue'], ['darkgreen', 'darkgreen'], ['darkmagenta', 'darkmagenta'], ['darkcyan', 'darkcyan']]\n```\n\n#### g:multiline_search_range\nDefault: `10`  \nThis settings is only relevant for rfc_csv and rfc_semicolon dialects.  \nIf some multiline records contain more lines that this value, hover info will not work correctly. It is not recommended to significantly increase this value because it will have negative impact on hover info performance \n\n#### g:rbql_backend_language\nDefault: `'python'`  \nSupported values: `'python'`, `'js'`  \n\nScripting language to use in RBQL expressions.\n\n\n#### g:rbql_encoding\nDefault: `utf-8`  \nSupported values: `'utf-8'`, `'latin-1'`  \n\nCSV files encoding for RBQL. \n\n\n#### g:rbql_output_format\nDefault: `'input'`  \nSupported values: `'tsv'`, `'csv'`, `'input'`\n\nFormat of RBQL result set tables.\n\n* input: same format as the input table\n* tsv: doesn't allow quoted tabs inside fields. \n* csv: is Excel-compatible and allows quoted commas.\n\nEssentially format is a pair: delimiter + quoting policy.  \nThis setting for example can be used to convert files between tsv and csv format:\n* To convert _csv_ to _tsv_: **1.** open csv file. **2.** `:let g:rbql_output_format='tsv'` **3.** `:Select *`\n* To convert _tsv_ to _csv_: **1.** open tsv file. **2.** `:let g:rbql_output_format='csv'` **3.** `:Select *`\n\n\n#### g:rbql_use_system_python\nSet to `1` to use system python interpreter for RBQL queries instead of the python interpreter built into your vim/neovim editor.\n\n\n#### g:rbql_with_headers\nIf most of the CSV files that you work with have headers, you can set this value to 1. In this case RBQL will treat first records in files as headers by default.  \nExample: `:let g:rbql_with_headers = 1`  \nYou can also adjust (or override) this setting by adding `WITH (header)` or `WITH (noheader)` to the end of your RBQL queries.\n\n#### g:rbql_trim_spaces\nDefault: `1`  \nTrim/Strip all trailing and leading spaces in all fields when running RBQL.  \nSet to `0` to preserve leading and trailing spaces in output, this might also slightly improve performance.\n\n\n# RBQL (Rainbow Query Language) Description\n\nRBQL is an eval-based SQL-like query engine for (not only) CSV file processing. It provides SQL-like language that supports SELECT queries with Python or JavaScript expressions.  \nRBQL is best suited for data transformation, data cleaning, and analytical queries.  \nRBQL is distributed with CLI apps, text editor plugins, Python and JS libraries.  \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* Supports multiple input formats\n* Result set of any query immediately becomes a first-class table on its own\n* No need to provide FROM statement in the query when the input table is defined by the current context.\n* Supports all main SQL keywords\n* Supports aggregate functions and GROUP BY queries\n* Supports user-defined functions (UDF)\n* Provides some new useful query modes which traditional SQL engines do not have\n* Lightweight, dependency-free, works out of the box\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* AS\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 header 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 header\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.\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_, _ANY_VALUE_, _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 its file path or by its name - an arbitrary string which the 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 the left table \"A\" doesn't have exactly one matching key in the right table \"B\".  \nTable B path can be either relative to the working dir, relative to the main table or absolute.  \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### 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### WITH (header) and WITH (noheader) statements\nYou can set whether the input (and join) CSV file has a header or not using the environment configuration parameters which could be `--with_headers` CLI flag or GUI checkbox or something else.\nBut it is also possible to override this selection directly in the query by adding either `WITH (header)` or `WITH (noheader)` statement at the end of the query.\nExample: `select top 5 NR, * with (header)`\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 a.id, a.weight / 1000 AS weight_kg`\n* `SELECT * ORDER BY random.random()` - random sort\n* `SELECT len(a.vehicle_price) / 10, a2 WHERE int(a.vehicle_price) \u003c 500 and a['Vehicle type'] in [\"car\", \"plane\", \"boat\"] limit 20` - referencing columns by names from 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* `SELECT *a1.split(':')` - Using Python3 unpack operator to split one column into many. Do not try this with other SQL engines!\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 a.id, a.weight / 1000 AS weight_kg`\n* `SELECT * ORDER BY Math.random()` - random sort\n* `SELECT TOP 20 a.vehicle_price.length / 10, a2 WHERE parseInt(a.vehicle_price) \u003c 500 \u0026\u0026 [\"car\", \"plane\", \"boat\"].indexOf(a['Vehicle type']) \u003e -1 limit 20` - referencing columns by names from 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* `SELECT ...a1.split(':')` - Using JS \"destructuring assignment\" syntax to split one column into many. Do not try this with other SQL engines!\n\n\n# General info\n\n### Comparison of Rainbow CSV technology with traditional graphical column alignment\n\n#### Advantages\n\n* WYSIWYG  \n* Familiar editing environment of your favorite text editor  \n* Zero-cost abstraction: Syntax highlighting is essentially free, while graphical column alignment can be computationally expensive  \n* High information density: Rainbow CSV shows more data per screen because it doesn't insert column-aligning whitespaces.\n* Works with non-table and semi-tabular files (text files that contain both table(s) and non-table data like text)\n* Ability to visually associate two same-colored columns from two different windows. This is not possible with graphical column alignment  \n\n#### Disadvantages\n\n* Rainbow CSV technology may be less effective for CSV files with many (\u003e 10) columns\n\n### References\n\n\n#### Rainbow CSV and similar plugins in other editors:\n\n* Rainbow CSV for [Neovim](https://github.com/cameron-wags/rainbow_csv.nvim) - fork of Vim plugin, has some improvements and optimizations.\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 in [IntelliJ IDEA](https://plugins.jetbrains.com/plugin/12896-rainbow-csv/)\n* CSVLint for [Notepad++](https://github.com/BdR76/CSVLint)\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 package in [Atom](https://atom.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\n#### RBQL\n\n* RBQL [website](https://rbql.org/)\n* Library and CLI App for [JavaScript](https://www.npmjs.com/package/rbql)\n* Library and CLI App for [Python](https://pypi.org/project/rbql/)\n* Demo Google Colab IPython [notebook](https://colab.research.google.com/drive/1_cFPtnQUxILP0RE2_DBlqIfXaEzT-oZ6?usp=sharing)\n\n#### Related vim plugins:\nRainbow CSV name and original implementation was significantly influenced by [rainbow_parentheses](https://github.com/kien/rainbow_parentheses.vim) Vim plugin.  \n\nThere also exists an old vim syntax file [csv_color](https://vim.sourceforge.io/scripts/script.php?script_id=518) which, despite it's name, can highlight only *.tsv files.  \nAnd, of course, there is [csv.vim](https://github.com/chrisbra/csv.vim)\n\n","funding_links":[],"categories":["Python","语言资源库","Tools","Shell"],"sub_categories":["python","Editors"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechatroner%2Frainbow_csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmechatroner%2Frainbow_csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechatroner%2Frainbow_csv/lists"}