Extending VisiData With Plugins

VisiData allows users to extend the program’s functionality through plugins. You can write your own, or use plugins other people have written. This chapter focuses on incorporating already-written plugins.

How to install a plugin

Installing a plugin so involves two steps:

  • First, make the plugin available to VisiData. Depending on the plugin, you’ll do this either by saving the plugin file to your ~/.visidata/ directory, or by running pip install [plugin_package_name].
  • Then, use your ~/.visidatarc configuration file to import the plugin. If you’ve saved your plugin as ~/.visidata/myplugin.py, all you need to do is add a line that says import myplugin.

Example

To demonstrate, let’s install a “dedupe” plugin:

  • Open this file in your browser and save it to ~/.visidata/dedupe.py on your computer.
  • Open your ~/.visidatarc file, add import dedupe on a new line, and save the file.

That’s it. Next time you start VisiData, you should have access to two new commands: select-duplicate-rows and dedupe-rows.

Let’s give the plugin a spin. Download dedupe-example.csv and open it in VisiData:

vd dedupe-example.csv

You should see this:

  File  Edit  View  Column  Row  Data  Plot  System  Help     | VisiData 3.0.2 | Alt+H for help men
 animal  name    dog    │ Apollo ║
 dog     Bambi   dog     Cutie   fish    Fido    fish    Fido                                                      ┌─────────────────────────────────| statuses |─┐
                                                   │ saul.pw/VisiData v3.0.2                                                                         │ opening datasets/dedupe-example.csv as csv                                                      │ I can see you're trying to invent something! │
                                                   └──────────────────────────────────────────────┘
1› dedupe-example|                                                                          5 rows 

Press Space to initiate the longname-command prompt, and type dedupe-rows:

  File  Edit  View  Column  Row  Data  Plot  System  Help     | VisiData 3.0.2 | Alt+H for help men
 animal  name    dog    │ Apollo ║
 dog     Bambi   dog     Cutie   fish    Fido    fish    Fido                                                    ┌─────────────────────────────| Choose Command |─┐
                                                 │ Start typing a command longname or keyword in  │
                                                 │ its helpstring.                                              dedupe-rows                                                                                 *    addcol-regex-subst - add column der│ - Enter to execute top command.                              addcol-subst - add column derived f│ - Tab to highlight top command.                         ]    sort-desc - sort descending by curr                                                        g]    sort-keys-desc - sort descending by## When Command Highlighted                             )    contract-col - remove current colum                                                        z)    contract-col-depth - remove current│ - Tab/Shift+Tab to cycle highlighted command.     Shift+D    cmdlog-sheet - open current sheet's│ - Enter to execute highlighted command.          gShift+Y    syscopy-selected - yank (copy) sele│ - 0-9 to execute numbered command.             │
 gzShift+Y    syscopy-cells - yank (copy) content└────────────────────────────────────────────────┘
command name: dedup                                          Space   exec-longname          5 rows 

Press Enter to execute the command. Now you should see a new copy of the sheet, but with the duplicate row removed:

  File  Edit  View  Column  Row  Data  Plot  System  Help     | VisiData 3.0.2 | Alt+H for help men
 animal  name    dog    │ Apollo ║
 dog     Bambi   dog     Cutie   fish    Fido                                                         ┌──────────────────────────────| statuses |─┐
                                                      No key cols specified. Using all columns.                                                      └───────────────────────────────────────────┘
2› dedupe-example_deduped|                                                Space             4 rows 

Where to find plugins

Here is a (likely incomplete) list of resources:

Warning

As with any software you download, plugins may contain malicious code. If you’re unsure whether a plugin is safe to install, err on the side of caution.