Edit CSV files from the command line.
pip install csveditor==0.0.0.11
Lightweight command-line editor for CSVs too large for tools such as Excel.
Edit operations are pipeline-backed, meaning you can create your pipeline using a "preview" portion of the table and defer modifying the underlying data until the table is actually saved.
CꜱᴠEᴅɪᴛᴏʀ uses the Iɴᴛᴇʀᴍᴀᴋᴇ library, and therefore supports multiple modes of operation: command-line, command-line-interactive, python-interactive-shell, python-scripting, Jupyter, basic GUI, etc.
Please install using pip:
(sudo) pip install csveditor
csveditor
to launch the program in CLI mode.cmdlist
command to get an idea of what you can do.sequence
#
, e.g. #2
:
, e.g. data:#2
for column 2 of the data
table.5
for row 5 of the current table.Our aim in this example is to join two bioinformatics tables together based on a common column, family:
First we open up our left table
$ open /Users/martinrusilowicz/examples/left.csv
We take a peek to make sure the data loaded okay:
$ head
-------------------- 0 --------------------
0 id [11532]
1 family [F11532]
2 eccentricity [6]
...
It loaded fine, so we load our right table. It has a longer filename, so we provide an abbreviation - "right".
$ open /Users/martinrusilowicz/examples/the-right-table.csv right
We take another peek:
$ head
-------------------- 0 --------------------
0 sequence [ NZ_JQAK01000007|gi|692233712]
1 family [ F0]
We see some some unwanted space, e.g. " F0"
instead of "F0"
. We can fix that by being more specific about the CSV dialect we are using:
$ dialect +trim
Now we've fixed the dialect we can check again:
$ head
-------------------- 0 --------------------
0 sequence [NZ_JQAK01000007|gi|692233712]
1 family [F0]
Notice how we don't need to reload our table to change the dialect.
Now we can join our tables together. When we loaded the right table that table became active, use the switch
command to go back to the left table:
$ switch left
And add the join operation to our pipeline:
$ join family right:family
Take a peek to see if it worked:
$ summary
Initial: 5787 rows
Initial: 23 columns
Final: 45484 rows
Final: 24 columns
We see that our new table has a lot more rows, so the join
probably worked, we could do some more in depth exploration using head
or view
, but for now let's just save the table:
$ save /Users/martinrusilowicz/examples/leftright.csv
That's it.
author = Martin Rusilowicz
licence = https://www.gnu.org/licenses/agpl-3.0.html
date = 2017
keywords= csv, tsv, editor, viewer, command-line, cli
language= python3
type = cli
os = independent
host = bitbucket,pypi
type = arg,cli