[CENTOS] [Linux convenient command] Try inserting csview

environment

Overview

I often handle csv in my work. There seems to be a csv viewer in CUI, so I will put it in

https://github.com/wfxr/csview

Installation

#download
$ curl -OL https://github.com/wfxr/csview/releases/download/v0.3.5/csview-v0.3.5-x86_64-unknown-linux-gnu.tar.gz

#Defrost
$ tar -zxvf csview-v0.3.5-x86_64-unknown-linux-gnu.tar.gz
$ cd csview-v0.3.5-x86_64-unknown-linux-gnu

#Move to where the pass passes
$ sudo mv csview /usr/local/bin/

It's easy.

Then practice!

#Run
$ csview a.csv

Then

An error occurs if Glibc 2.18 is not found !!

$ sudo yum update glibc

I will try to update with, but it seems that there is only up to 2.17.

Then

https://omohikane.com/deno_not_found_glibc_218/

It seems that you can manually update glibc by referring to the article in, so I will try it.

Install Glibc 2.18

$ cd /tmp
$ wget https://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
$ tar -zxvf glibc-2.18.tar.gz
$ cd glibc-2.18
$ mkdir build
$ cd build
$ ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
$ make && make install

$ ldd --version
ldd (GNU libc) 2.18
Copyright (C) 2013 Free Software Foundation, Inc.

The glibc is now 2.18. .. It was good.

Regain your mind and practice csview again!

The character code is different !!

$ csview a.csv
[error] input is not utf8 encoded

Another error. It is useless if the character code is not utf8.

You can go by biting iconv as described in the README of github of csview.

$ iconv -f shift-jis -t UTF8//TRANSLIT a.csv| csview
+-------------+----------+----------------+
|code|name|Description|
+-------------+----------+----------------+
| abc         |eraser|It disappears often|
| ABCDEFGHIJK |Pencil|Easy to hold|
|             |          |The core is also hard to break|
+-------------+----------+----------------+

I was able to go! !! !! !! : clap:

Check the type of appearance

$ ./csview --help
csview 0.3.5
A high performance csv viewer with cjk/emoji support.

USAGE:
    csview [FLAGS] [OPTIONS] [FILE] [SUBCOMMAND]

FLAGS:
    -h, --help          Prints help information
    -H, --no-headers    Specify that the input has no header row
    -t, --tsv           Use '\t' as delimiter for tsv, overrides '-d' option
    -V, --version       Prints version information

OPTIONS:
        --style <border>           Specify the border style [default: Ascii]  [possible values: None, Ascii, Sharp, Rounded, Reinforced, Markdown, Grid]
    -d, --delimiter <delimiter>    Specify the field delimiter [default: ,]

ARGS:
    <FILE>    File to read

SUBCOMMANDS:
    completion    Generate shell completion file
    help          Prints this message or the help of the given subcommand(s)

So, it seems that you can change it with --style.

$ iconv -f shift-jis -t UTF8//TRANSLIT a.csv| csview --style none
Code name Description
abc eraser It erases well
ABCDEFGHIJK It's easy to hold a pencil
The core is also hard to break
$ iconv -f shift-jis -t UTF8//TRANSLIT a.csv| csview --style ascii
+-------------+----------+----------------+
|code|name|Description|
+-------------+----------+----------------+
| abc         |eraser|It disappears often|
| ABCDEFGHIJK |Pencil|Easy to hold|
|             |          |The core is also hard to break|
+-------------+----------+----------------+
$ iconv -f shift-jis -t UTF8//TRANSLIT a.csv| csview --style sharp
┌─────────────┬──────────┬────────────────┐
│ Code │ Name │ Description │
├─────────────┼──────────┼────────────────┤
│ abc │ Eraser │ It disappears well │
│ ABCDEFGHIJK │ Pencil │ Easy to hold │
│ │ │ The core is also hard to break │
└─────────────┴──────────┴────────────────┘
$ iconv -f shift-jis -t UTF8//TRANSLIT a.csv| csview --style rounded
╭─────────────┬──────────┬────────────────╮
│ Code │ Name │ Description │
├─────────────┼──────────┼────────────────┤
│ abc │ Eraser │ It disappears well │
│ ABCDEFGHIJK │ Pencil │ Easy to hold │
│ │ │ The core is also hard to break │
╰─────────────┴──────────┴────────────────╯
$ iconv -f shift-jis -t UTF8//TRANSLIT a.csv| csview --style reinforced
┏─────────────┬──────────┬────────────────┓
│ Code │ Name │ Description │
├─────────────┼──────────┼────────────────┤
│ abc │ Eraser │ It disappears well │
│ ABCDEFGHIJK │ Pencil │ Easy to hold │
│ │ │ The core is also hard to break │
┗─────────────┴──────────┴────────────────┛
$ iconv -f shift-jis -t UTF8//TRANSLIT a.csv| csview --style markdown
|code|name|Description|
|-------------|----------|----------------|
| abc         |eraser|It disappears often|
| ABCDEFGHIJK |Pencil|Easy to hold|
|             |          |The core is also hard to break|
$ iconv -f shift-jis -t UTF8//TRANSLIT a.csv| csview --style grid
┌─────────────┬──────────┬────────────────┐
│ Code │ Name │ Description │
├─────────────┼──────────┼────────────────┤
│ abc │ Eraser │ It disappears well │
├─────────────┼──────────┼────────────────┤
│ ABCDEFGHIJK │ Pencil │ Easy to hold │
│ │ │ The core is also hard to break │
└─────────────┴──────────┴────────────────┘

I usually handle csv where line breaks are often done, so personally grid is the best.

alias

It is troublesome to specify iconv every time, so I will prepare an alias (function).

Since it is a conversion to shift-jis, I changed it to csviews with csview + s. .. By the way, I will also put the style of the display

function csviews() {
  command iconv -f shift-jis -t UTF8//TRANSLIT $1 | csview --style grid
}
$ csviews a.csv 
┌─────────────┬──────────┬────────────────┐
│ Code │ Name │ Description │
├─────────────┼──────────┼────────────────┤
│ abc │ Eraser │ It disappears well │
├─────────────┼──────────┼────────────────┤
│ ABCDEFGHIJK │ Pencil │ Easy to hold │
│ │ │ The core is also hard to break │
└─────────────┴──────────┴────────────────┘

Ah convenient.

Summary

It seems to be difficult when looking at big things, but when it is troublesome to open it with software with a little confirmation ... It seems very convenient.

On qiita, the lines are separated because the padding between the lines is effective, but on the actual console, the lines are neatly attached and drawn. If you are interested, please give it a try.

Recommended Posts

[Linux convenient command] Try inserting csview
[Linux convenient command] Try inserting exa
[Linux convenient command] Try inserting bat
[Linux convenient command] Try to insert vivid
Linux command # 4
Linux command # 3
Linux command # 5
Linux command list
linux at command
Linux command <Basic 2>
Linux [directory command]
Linux server command
Linux # Command Memo 1
Linux command [read]
Linux Command Summary
[Basic] linux command
Linux [shell command]
Convenient command combination
[Linux] Command / Knowledge
My linux command
Linux command <Basic 1>
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Linux (command memory)
Try to create a new command on linux
[Linux] Volume configuration command
Linux command cheat sheet
Linux command (sequential update)
Linux basic command memorandum
Linux command [File operation]
[Linux] Basic command summary
Linux command for self-collection
linux command error collection 1
Try NeosVR on Linux
Linux command line shortcut
linux sar command CPU usage
[Linux] tar.gz compression / decompression command
Try normal Linux programming Part 7
Try normal Linux programming Part 2
Convenient diff command usage notes
Try normal Linux programming Part 3
Try normal Linux programming Part 4
Easy df command on Linux
Linux tar xz command memo
Try normal Linux programming Part 6
Linux Command Dictionary (for myself)
linux: create original Terminal command
[Note] Useful linux command collection
Linux command memorandum [for beginners]
Linux PC spec check command
[Linux] User / group command summary
Convenient Linux shortcuts (for beginners)