"CSVI" - Terminal CSV Editor

GoDev

<English> / <Japanese>

CSVI is a terminal-based CSV editor for UNIX-like systems and Windows.

✨ Key Features

image

Video by @emisjerry

Install

Manual Installation

Download the binary package from Releases and extract the executable.

⚠️ Note: The macOS build is experimental and not yet tested. Please let us know if you encounter any issues!

Use "go install"

go install github.com/hymkor/csvi/cmd/csvi@latest

Use scoop-installer (Windows only)

scoop install https://raw.githubusercontent.com/hymkor/csvi/master/csvi.json

or

scoop bucket add hymkor https://github.com/hymkor/scoop-bucket
scoop install csvi

Usage

$ csvi {options} FILENAME(...)

or

$ cat FILENAME | csvi {options}

Options

Key-binding

Environment Variables

NO_COLOR

If the environment variable NO_COLOR is set to any value with at least one character, csvi disables colored output. This follows the standard proposed by NO_COLOR.

RUNEWIDTH_EASTASIAN

Specifies the display width for Unicode characters classified as ambiguous width.

COLORFGBG

When the environment variable is defined in the form (FG);(BG) and the foreground (FG) is less than the background (BG), csvi automatically uses color settings suitable for light backgrounds (equivalent to the -rv option).

csvi normally uses the terminal's default colors via the escape sequences ESC[39m and ESC[49m. Thus, the (FG);(BG) values are not directly applied; they are only used to determine whether gray background lines should be adjusted toward light or dark shades.

GOREADLINESKK

When the environment variable GOREADLINESKK specifies dictionary files, the built-in SKK1 Kana-to-Kanji conversion via go-readline-skk is enabled.

(Note: ~ is automatically expanded to %USERPROFILE% on Windows, even in cmd.exe.)

Use as a Go package

package main

import (
    "fmt"
    "os"
    "strings"

    "github.com/mattn/go-colorable"

    "github.com/hymkor/csvi"
    "github.com/hymkor/csvi/uncsv"
)

func main() {
    source := `A,B,C,D
"A1","B1","C1","D1"
"A2","B2","C2","D2"`

    cfg := &csvi.Config{
        Mode: &uncsv.Mode{Comma: ','},
    }

    result, err := cfg.Edit(strings.NewReader(source), colorable.NewColorableStdout())

    if err != nil {
        fmt.Fprintln(os.Stderr, err.Error())
        os.Exit(1)
    }

    // // env GOEXPERIMENT=rangefunc go run example
    // for row := range result.Each {
    //     os.Stdout.Write(row.Rebuild(cfg.Mode))
    // }
    result.Each(func(row *uncsv.Row) bool {
        os.Stdout.Write(row.Rebuild(cfg.Mode))
        return true
    })
}

Release Note

Acknowledgements

Author


  1. Simple Kana to Kanji conversion program. One of the Japanese input method editors. ↩︎