XSV for fast CSV manipulations - Part 1: Basic Usage
xsv is a command line program for indexing, slicing, analyzing, splitting and joining CSV files. Commands should be simple, fast and composable:
- Simple tasks should be easy.
- Performance trade offs should be exposed in the CLI interface.
- Composition should not come at the expense of performance.
We will be using the CSV file provided in the documentation.
Commands covered in this episode
- count - Count the rows of CSV data
- headers - Show the headers of CSV data, or show the intersection of all headers between many CSV files
- index - Create an index for a CSV file. This is very quick and provides constant time indexing into the CSV file.
- frequency - Build frequency tables of each column in CSV data.
- stats - Show basic types and statistics of each column in the CSV file. (i.e., mean, standard deviation, median, range, etc.)
- sort - Sort CSV data
- select - Select or re-order columns from CSV data.
- slice - Slice rows from any part of a CSV file. When an index is present, this only has to parse the rows in the slice (instead of all rows leading up to the start of the slice).
- search - Run a regex over CSV data. Applies the regex to each field individually and shows only matching rows.
- table - Show aligned output of any CSV data using elastic tabstops.
- flatten - A flattened view of CSV records. Useful for viewing one record at a time.