Opening Files

The first skill we’ll learn is the most basic: How to open (and close) a dataset in VisiData.

How to open a file

The easiest way to open a dataset in VisiData is to specify it directly when invoking vd, like so:

vd faa-wildlife-strikes.csv

If you’ve downloaded the faa-wildlife-strikes.csv file, and you run the command above, you should see this:

 OPERATOR           | ATYPE          | INCIDENT_DATE      | STATE   | AIRPORT            | PHASE_O> 
 BUSINESS           | PA-28          | 05/22/15 00:00:00  | FL      | VERO BEACH MUNICIP…| APPROACH 
 BUSINESS           | BE-1900        | 06/18/15 00:00:00  | AK      | KENAI MUNICIPAL AR…| APPROACH 
 BUSINESS           | PA-46 MALIBU   | 09/20/15 00:00:00  | TX      | DAVID WAYNE HOOKS …|          
 DELTA AIR LINES    | B-717-200      | 11/07/15 00:00:00  | MO      | LAMBERT-ST LOUIS I…| APPROACH 
 BUSINESS           | BE-90 KING     | 12/17/15 00:00:00  | FL      | POMPANO BEACH AIRP…| LANDING… 
 DELTA AIR LINES    | B-757          | 07/17/15 00:00:00  | VI      | HENRY E ROHLSEN AR…|          
 DELTA AIR LINES    | B-717-200      | 08/02/15 00:00:00  | TX      | SAN ANTONIO INTL   | APPROACH 
 BUSINESS           | C-414          | 08/03/15 00:00:00  | TX      | LONE STAR EXECUTIV…| DEPARTU… 
 ALLEGIANT AIR      | MD-80          | 09/02/15 00:00:00  | FL      | TAMPA INTL         | APPROACH 
 TRANS STATES AIRLI…| EMB-145        | 09/07/15 00:00:00  | MO      | LAMBERT-ST LOUIS I…| APPROACH 
 BUSINESS           | C-172          | 11/28/15 00:00:00  | FL      | OPA-LOCKA EXECUTIV…| APPROACH 
 GOVERNMENT         | EC120          | 12/08/15 00:00:00  | CA      | NORMAN Y. MINETA S…|          
 AMERICAN AIRLINES  | A-321          | 05/06/15 00:00:00  | FL      | FORT LAUDERDALE/HO…| APPROACH 
 EXPRESSJET AIRLINES| CRJ100/200     | 05/06/15 00:00:00  | AR      | FORT SMITH REGIONA…| CLIMB    
 MESA AIRLINES      | CRJ900         | 05/08/15 00:00:00  | AR      | BILL AND  HILLARY …| LANDING… 
 BUSINESS           | HELICOPTER     | 05/06/15 00:00:00  |         | UNKNOWN            | En Route 
 DELTA AIR LINES    | A-320          | 05/07/15 00:00:00  | CA      | METRO OAKLAND INTL |          
 DELTA AIR LINES    | A-320          | 05/08/15 00:00:00  | UT      | SALT LAKE CITY INTL|          
 LUFTHANSA          | A-380          | 05/10/15 00:00:00  | TX      | GEORGE BUSH INTERC…| CLIMB    
 BUSINESS           | C-172          | 05/08/15 00:00:00  | FL      | ORLANDO SANFORD IN…| APPROACH 
 SPIRIT AIRLINES    | A-319          | 05/10/15 00:00:00  | IL      | CHICAGO O'HARE INT…| CLIMB    
 EXPRESSJET AIRLINES| EMB-145        | 05/11/15 00:00:00  | AL      | BIRMINGHAM-SHUTTLE…| LANDING… 
faa-wildlife-strikes| saul.pw/VisiData v1.5 | opening faa-wildlife-strikes as csv       73448 rows… 

Let’s break it down:

  • Top row
    • Displays your dataset’s columns — at least as many as can fit on your screen.
  • Bottom row
    • Tells you what dataset you’re viewing (faa-wildlife-strikes on the far left), some status information, and the number of rows.
  • Highlighted column and row
    • Indicate your current position in the dataset.

Note

Depending on the width and height of your terminal, you’ll see more/fewer columns and rows.

How to close a file

If you’ve just opened a single file, you can close it by typing q.

If you’ve opened a collection of files — more on that later — you can close them all at once by typing gq.

How to specify the file’s format

VisiData guesses which kind of file you’re trying to open based on the file’s extension. For instance, it will try to open my-csv-data.xlsx as an Excel file. To override that default, specify the filetype with the --filetype flag. For instance:

vd my-csv-data.xlsx --filetype csv

You can also use the shorter -f flag:

vd my-csv-data.xlsx -f csv

Compatible filetypes

VisiData can open a range of filetypes, including:

Tabular data

  • CSV files, and any other delimiter-separated formats
  • Excel spreadsheets (requires pip3 install xlrd openpyxl)
  • Fixed-width files
  • SQLite databases
  • Postgres databases (requires pip3 install psycopg2)
  • HDF5 files (requires pip3 install h5py)
  • .sas7bdat files (requires pip3 install sas7bdat)
  • .xpt files (requires pip3 install xport)
  • .sav files (requires pip3 install savReaderWriter)
  • .dta files (requires pip3 install pandas)

Nested Data

  • JSON / JSONL
  • XML (requires pip3 install lxml)
  • YAML (requires pip3 install PyYAML)

Geospatial data

  • Shapefiles (requires pip3 install pyshp)
  • MBTiles (requires pip3 install mapbox-vector-tile)

Directories

  • Standard Unix directories
  • ZIP files

Misc.

  • HTML (looks for <table> tags; requires pip3 install lxml)
  • Website URLs (downloads the HTML, and then looks for <table> tags; requires pip3 install lxml)
  • .pcap files (requires pip3 install dpkt dnslib)