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.

Using VisiData’s plugin installer

VisiData provides an interface for installing certain plugins. To open the interface, press Space to raise the longname-command prompt, type open-plugins, and press Enter:

 name        instal…| description                            | maintainer         | latest_releas> 
 vfake      ║        | replace column with fake values        | Saul Pwanson @saul…| 2020-10-06     
 dedupe             | adds commands for selection and remova…| Jeremy Singer-Vine…| 2020-10-11     
 normcol            | normalizes column names in any given s…| Jeremy Singer-Vine…| 2020-10-11     
 fec                | loader for .fec files from the Federal…| Jeremy Singer-Vine…| 2019-04-21     
 sparkline          | add a sparkline column to visualise tr…| Lucas Messenger @l…| 2020-09-13     
 rownum             | add column of original row ordering    | Saul Pwanson @saul…| 2019-11-07     
 vmailcap           | add mailcap-view(-selected) commands t…| Saul Pwanson @saul…| 2020-10-06     
 vmutagen           | add mp3 metadata columns to DirSheet   | Saul Pwanson @saul…| 2019-09-25     
 vds3               | add support for Amazon S3 paths        | AJ Kerrigan @ajker…| 2021-04-08     
 genericSQL         | add loaders for SQL databases (Oracle,…| Andrew Swanson @as…| 2020-04-15     
 diff               | adds command to create diff sheets     | Anja Kefala @anjak…| 2020-10-09     
 marks              | adds commands for marking selected row…| Saul Pwanson @saul…| 2020-10-09     
 conll              | CoNLL data loader                      | Paul McCann <polm@…| 2020-12-07     
 darkdraw           | textart and animation for the terminal…| devottys @devottys | 2021-05-03     
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
3› plugins_global| "open-plugins"                                                    14 plugins  •0 

To install and activate any of these plugins, navigate to its row and press a. To deactivate a plugin, navigate to its row and press d.

How to install a plugin manually

You can also manually install plugins that are not available through the installer. Doing 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:

 animal | name                                                                                     
 dog    | Apollo ║                                                                                  
 dog    | Bambi                                                                                    
 dog    | Cutie                                                                                    
 fish   | Fido                                                                                     
 fish   | Fido                                                                                     
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
1› dedupe-example| saul.pw/VisiData v2.5 | opening datasets/dedupe-example.cs            5 rows  •0 

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

 animal | name                                                                                     
 dog    | Apollo ║                                                                                  
 dog    | Bambi                                                                                    
 dog    | Cutie                                                                                    
 fish   | Fido                                                                                     
 fish   | Fido                                                                                     
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
command name: dedupe-rows                                          exec-longname         5 rows  •0 

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

 animal | name                                                                                     
 dog    | Apollo ║                                                                                  
 dog    | Bambi                                                                                    
 dog    | Cutie                                                                                    
 fish   | Fido                                                                                     
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
2› dedupe-example_deduped| No key cols specified. Using all columns. | "dedu             4 rows  •0 

Where to find plugins

Plugin support is a relatively new feature of VisiData, so there aren’t many public plugins yet available. 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.