Advanced CSV
Efficiently format, edit, arrange, and evaluate cells in CSV files
Details
Installs
- Total 88K
- Win 41K
- Mac 34K
- Linux 14K
Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | Nov 5 | Nov 4 | Nov 3 | Nov 2 | Nov 1 | Oct 31 | Oct 30 | Oct 29 | Oct 28 | Oct 27 | Oct 26 | Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | Oct 19 | Oct 18 | Oct 17 | Oct 16 | Oct 15 | Oct 14 | Oct 13 | Oct 12 | Oct 11 | Oct 10 | Oct 9 | Oct 8 | Oct 7 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 2 | 1 | 2 | 2 | 5 | 3 | 7 | 0 | 0 | 12 | 4 | 2 | 2 | 4 | 6 | 9 | 1 | 9 | 5 | 1 | 1 | 2 | 6 | 7 | 4 | 2 | 0 | 4 | 6 | 6 | 3 | 5 | 2 | 2 | 6 | 8 | 5 | 8 | 6 | 2 | 5 | 7 | 6 | 9 | 8 | 7 |
Mac | 1 | 4 | 0 | 4 | 1 | 2 | 5 | 0 | 0 | 12 | 5 | 0 | 1 | 6 | 6 | 8 | 6 | 11 | 1 | 4 | 3 | 7 | 2 | 13 | 4 | 0 | 2 | 2 | 4 | 8 | 7 | 7 | 1 | 1 | 9 | 7 | 6 | 5 | 8 | 3 | 2 | 2 | 7 | 7 | 3 | 7 |
Linux | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 2 | 3 | 3 | 1 | 2 | 2 | 1 | 0 | 1 | 2 | 1 | 1 | 0 | 5 | 2 | 0 | 0 | 0 | 1 | 1 | 1 | 3 | 0 | 0 | 1 | 3 | 5 | 3 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 2 | 2 |
Readme
- Source
- raw.githubusercontent.com
Sublime Text Advanced CSV
A plugin to manage CSV files, forked from Eric Martel's Sublime-Text-2-CSV-Plugin at https://github.com/ericmartel/Sublime-Text-2-CSV-Plugin.
It's often easiest to work with CSV data when the columns are properly lined up. This plugin provides a command to line up all the columns using spaces (Justify columns
) and to collapse them back again (Collapse columns
).
It also includes commands to insert and delete columns and to sort data by column, with or without a header row, and respecting numeric order and lexicographical order as appropriate.
An entire column may be block selected (Select column
), which enables complex operations like quickly reordering, merging, adding & deleting multiple columns.
The plugin includes a command to clean up empty trailing commas from rows, which are often left when opening a CSV file in Excel.
Using NumPy (http://www.numpy.org), the plugin supports evaluating Python expressions over ranges of cells, in a manner similar to formulas in Excel.
All the above features work in both justified and collapsed modes.
Finally, the plugin fully supports RFC 4180 (https://tools.ietf.org/html/rfc4180) quoting, with the exception that quoted newlines (2.6) are treated as row separators.
Install
The files can be obtained on GitHub:
$ https://github.com/wadetb/Sublime-Text-Advanced-CSV
Or via Package Control (https://sublime.wbond.net):
- Use the Package Control: Install Package command from the command palette.
- A list of packages will appear. Type
Advanced CSV
and press enter.
Using Package Control ensures that the Advanced CSV plugin stays up to date.
Key bindings
Key | Action |
---|---|
Ctrl+Comma, Up |
Sort by column (Ascending) |
Ctrl+Comma, Down |
Sort by column (Descending) |
Ctrl+Comma, i |
Insert column |
Ctrl+Comma, d |
Delete column |
Ctrl+Comma, s |
Select column |
Ctrl+Comma, Space |
Justify columns |
Ctrl+Comma, Comma |
Collapse columns |
Ctrl+Comma, Equals |
Evaluate cells |
Ctrl+Comma, f |
Format cells using a template string |
Formulas
To trigger cell evaluation, the contents of a cell must follow a standard pattern:
<range>=<python expression...>
range
defines the set of cells whose contents will be updated, and python expression
defines the Python expression that will be evaluated.
Ranges
If range
is left blank, the formula cell itself is replaced. Unlike Excel, the formula text is not stored separately from the displayed value, so this has the effect of destroying the formula, though the evaluate command can always be undone if that result is unwanted.
=<python expression>
Replaces the current cell with the result ofpython expression
.
The syntax for defining a range other than the formula cell is:
[<row_start>:<row_end>,<col_start>:<col_end>]=<python expression>
Updates a rectangular area of the document from row_start
to row_end
and from col_start
to col_end
. If row_start
or col_start
is omitted, the range starts at the first row or column of the document.
If row_end
or col_end
is omitted, the range ends at the last row or column of the document of the document. If both are omitted but the colon is included, the entire row are column is updated. If both numbers and the colon are omitted, the range is the formula's row or column.
Here are all the variations of this syntax:
[:]
Updates all cells in the current column.[<row_start>:<row_end>]
Updates cells in the current column fromrow_start
torow_end
.[<row_start>:]
Updates cells in the current column fromrow_start
to the end of the document.[:<row_end>]
Updates cells in the current column from the beginning of the document torow_end
.[,:]
Updates all cells in the current row.[,<col_start>:<col_end>]
Updates all cells in the current row fromcol_start
tocol_end
.[,<col_start>:]
Updates all cells in the current row fromcol_start
to the end of the document.[,:<col_end>]
Updates all cells in the current row from the beginning of the document tocol_end
.[:,:]
Updates all cells in the document.[:,<col_start>:<col_end>]
Updates cells in all rows fromcol_start
tocol_end
.[:,<col_start>:]
Updates cells in all rows fromcol_start
to the end of the document.[:,:<col_end>]
Updates cells in all rows from the beginning of the documentto col_end
.
When defining ranges, the start
cell is updated, but the end
cell is not. This is intentional, to match NumPy array slice syntax.
[0:1,:]
Updates all cells in row 0.[1:3,:]
Updates all cells in rows 1 and 2.
Row and column numbers in ranges may be prefixed with +
or -
, which makes them relative to the formula's location in the document.
[:,-1]
Updates all cells in the column immediately to the left of the formula.[:,+1:+3]
Updates all cells in the two columns immediately to the right of the formula .
For convenience, the range may be shifted one cell in any direction by prefixing the =
character with a direction modifier.
<=
Updates the cell to the left of the formula.>=
Updates the cell to the right of the formula.^=
Updates the cell above the formula.v=
Updates the cell below the formula.
The range shift modifier may be used in conjunction with numeric ranges.
[:]<=
Updates all cells in the column to the left of the formula.
Expression syntax
The Python expression is evaluated by Sublime Text's Python interpreter, for each cell in the target range. The result is then converted to a string and stored in the cell.
Some variables are provided to the evaluator:
m
A NumPyndarray
representing the document. Non-numeric cells are represented with 0. The array dimensions are padded to the maximum extents of the document, missing cells are filled in with 0. For a NumPy tutorial, see http://wiki.scipy.org/Tentative_NumPy_Tutorial.row
The row of the cell being evaluated.col
The column of the cell being evaluated.frow
The row of the formula.fcol
The column of the formula.
Examples
Example 1
This example applies a simple column sum using the NumPy sum
method.
item ,price
shoes ,12
hat ,2
pants ,8
shirt ,7.50
total , ,"<=m[1:5,1].sum()"
Example 2
This example fills in totals by price and by item.
item ,price ,qty ,total
shoes ,12 ,2 ,
hat ,2 ,1 ,
pants ,8 ,1 ,
shirt ,7.50 ,2 ,
total , , ,
"[5,1:4]=m[1:5,col].sum()"
"[1:5,3]=m[row,1]*m[row,2]"
Note that it must be evaluated (Ctrl+Comma, Equals
) twice to calculate the last cell.
License
All of Sublime Text Advanced CSV Plugin is licensed under the MIT license.
Copyright © 2014 Wade Brainerd wadeb@wadeb.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Further, portions of the code taken from Eric Martel's Sublime Text 2 plugin are licensed as follows:
All of Sublime Text 2 CSV Plugin is licensed under the MIT license.
Copyright © 2012 Eric Martel emartel@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.