Skip to content
/ csview Public

πŸ“  Pretty and fast csv viewer for cli with cjk/emoji support.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

wfxr/csview

Repository files navigation

πŸ“  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


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.