#csv #pager #viewer #tool

app csview

A high performance csv viewer with cjk/emoji support

14 releases (5 stable)

Uses new Rust 2021

new 1.2.1 Sep 23, 2022
1.1.0 Jul 2, 2022
1.0.1 Feb 16, 2022
1.0.0-rc.1 Jan 5, 2022
0.3.5 Sep 23, 2020

#22 in Command line utilities

Download history 39/week @ 2022-06-06 8/week @ 2022-06-13 13/week @ 2022-06-20 37/week @ 2022-06-27 62/week @ 2022-07-04 45/week @ 2022-07-11 41/week @ 2022-07-18 33/week @ 2022-07-25 24/week @ 2022-08-01 15/week @ 2022-08-08 10/week @ 2022-08-15 25/week @ 2022-08-22 11/week @ 2022-08-29 43/week @ 2022-09-05 20/week @ 2022-09-12 72/week @ 2022-09-19

150 downloads per month

MIT/Apache

38KB
715 lines

📠 csview

A high performance csv viewer with cjk/emoji support.

CICD License Version Platform

Features

  • Small and fast (see benchmarks below).
  • Memory efficient.
  • Correctly align CJK and emoji characters.
  • Support tsv and custom delimiters.
  • Support different styles, including markdown table.

Usage

$ cat example.csv
Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00
1999,Chevy,"Venture ""Extended Edition, Large""",,5000.00
1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof",4799.00

$ csview example.csv
┌──────┬───────┬───────────────────────────────────┬───────────────────────────┬─────────┐
 Year │ Make  │               Model               │        Description        │  Price  │
├──────┼───────┼───────────────────────────────────┼───────────────────────────┼─────────┤
 1997 │ Ford  │ E350                              │ ac, abs, moon             │ 3000.00 │
 1999 │ Chevy │ Venture "Extended Edition"        │                           │ 4900.00 │
 1999 │ Chevy │ Venture "Extended Edition, Large" │                           │ 5000.00 │
 1996 │ Jeep  │ Grand Cherokee                    │ MUST SELL! air, moon roof │ 4799.00 │
└──────┴───────┴───────────────────────────────────┴───────────────────────────┴─────────┘

$ head /etc/passwd | csview -H -d:
┌────────────────────────┬───┬───────┬───────┬────────────────────────────┬─────────────────┐
 root                   │ x │ 0     │ 0     │                            │ /root           │
 bin                    │ x │ 1     │ 1     │                            │ /               │
 daemon                 │ x │ 2     │ 2     │                            │ /               │
 mail                   │ x │ 8     │ 12    │                            │ /var/spool/mail │
 ftp                    │ x │ 14    │ 11    │                            │ /srv/ftp        │
 http                   │ x │ 33    │ 33    │                            │ /srv/http       │
 nobody                 │ x │ 65534 │ 65534 │ Nobody                     │ /               │
 dbus                   │ x │ 81    │ 81    │ System Message Bus         │ /               │
 systemd-journal-remote │ x │ 981   │ 981   │ systemd Journal Remote     │ /               │
 systemd-network        │ x │ 980   │ 980   │ systemd Network Management │ /               │
└────────────────────────┴───┴───────┴───────┴────────────────────────────┴─────────────────┘

Run csview --help to view detailed usage.

Installation

On Arch Linux

csview is available in the Arch User Repository. To install it from AUR:

yay -S csview

On macOS

You can install csview with Homebrew:

brew install csview

On NetBSD

csview is available from the main pkgsrc Repositories. To install simply run

pkgin install csview

or, if you prefer to build from source using pkgsrc on any of the supported platforms:

cd /usr/pkgsrc/textproc/csview
make install

On Windows

You can install csview with Scoop:

scoop install csview

From binaries

Pre-built versions of csview for various architectures are available at Github release page.

Note that you can try the musl version (which is statically-linked) if runs into dependency related errors.

From source

csview is also published on crates.io. If you have latest Rust toolchains installed you can use cargo to install it from source:

cargo install --locked csview

If you want the latest version, clone this repository and run cargo build --release.

Benchmark

Tool Command Mean Time Min Time Memory
xsv xsv table small.csv 2.0ms 1.8ms 3.9mb
csview csview small.csv 0.3ms 0.1ms 2.4mb
column column -s, -t small.csv 1.3ms 1.1ms 2.4mb
csvlook csvlook small.csv 148.1ms 142.4ms 27.3mb
Tool Command Mean Time Min Time Memory
xsv xsv table medium.csv 0.031s 0.029s 4.4mb
csview csview medium.csv 0.017s 0.016s 2.8mb
column column -s, -t small.csv 0.052s 0.050s 9.9mb
csvlook csvlook medium.csv 2.664s 2.617s 46.8mb
  • large.csv (1,000,000 rows, 10 cols, 61M bytes, generated by concatenating medium.csv 100 times):
Tool Command Mean Time Min Time Memory
xsv xsv table large.csv 2.912s 2.820s 4.4mb
csview csview large.csv 1.686s 1.665s 2.8mb
column column -s, -t small.csv 5.777s 5.759s 767.6mb
csvlook csvlook large.csv 20.665s 20.549s 1105.7mb

F.A.Q.


We already have xsv, why not contribute to it but build a new tool?

xsv is great. But it's aimed for analyzing and manipulating csv data. csview is designed for formatting and viewing. See also: xsv/issues/156


Things look weird if the width of table is more than the width of terminal window.

Use pager less with -S option: csview a.csv | less -S so you can scroll screen horizontally. Or use xsv to filter out the columns you don't care then piped to csview.


I encountered UTF-8 related errors, how to solve it?

The file may use a non-UTF8 encoding. You can check the file encoding using file command:

$ file -i a.csv
a.csv: application/csv; charset=iso-8859-1

And then convert it to utf8:

$ iconv -f iso-8859-1 -t UTF8//TRANSLIT a.csv -o b.csv
$ csview b.csv

Or do it in place:

$ iconv -f iso-8859-1 -t UTF8//TRANSLIT a.csv | csview

Credits

License

csview is distributed under the terms of both the MIT License and the Apache License 2.0.

See the LICENSE-APACHE and LICENSE-MIT files for license details.

Dependencies

~4–10MB
~174K SLoC