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:

  File  Edit  View  Column  Row  Data  Plot  System  Help     | VisiData 3.0.2 | Alt+H for help men
 OPERATOR            ATYPE         INCIDENT_DATE      STATE  AIRPORT             PHASE_OF_FLT>
 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 ROLL  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… DEPARTURE     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 ROLL  BUSINESS            HELICOPTER    05/06/15 00:0┌──────────────────────────────────| statuses |─┐ DELTA AIR LINES     A-320         05/07/15 00:0│ saul.pw/VisiData v3.0.2                        DELTA AIR LINES     A-320         05/08/15 00:0│ opening datasets/faa-wildlife-strikes.csv as  │ LUFTHANSA           A-380         05/10/15 00:0│ csv                                            BUSINESS            C-172         05/08/15 00:0│ As if I would talk on such a subject!         │ SPIRIT AIRLINES     A-319         05/10/15 00:0└───────────────────────────────────────────────┘1› faa-wildlife-strikes|                                                                73448 rows 

Let’s break it down:

  • Top row (directly below the menu): This displays your dataset’s columns — at least as many as can fit on your screen.
  • Sidebar (the green box): This contains status messages based on what you have just done or usage guidance for multi-step commands.
  • Bottom row: This tells you what dataset you’re viewing (faa-wildlife-strikes on the far left), often some status information, the number of rows loaded (73,448).
  • Highlighted column and row: These 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)
  • MySQL databases (requires pip3 install mysqlclient)
  • 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

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)
  • .rec files
  • .pcap files (requires pip3 install dpkt dnslib)
  • and more