csvlint CSV file validity check

Checking CSV File Validity Using csvlint

In programming and computer work, there are many situations where CSV format files are handled. This article uses the 'csvlint' library to perform syntax checks, grammar checks, that is, error checks on CSV data, efficiently verifying its validity.

Shou Arisaka
1 min read
Oct 14, 2025

In programming and computer work, there are many situations where CSV format files are handled. This article uses the “csvlint” library to perform syntax checks, grammar checks, that is, error checks on CSV data, efficiently verifying its validity.

# install

[[ ! -d "${HOME}/go" ]] && mkdir ${HOME}/go
export GOPATH=${HOME}/go
export PATH=$PATH:$GOPATH/bin

go get github.com/Clever/csvlint/cmd/csvlint

Image

Clever/csvlint: library and command line tool that validates a CSV file

If there are errors, it will error

$ csvlint hoge.csv
Record #44 has error: wrong number of fields in line
Record #53 has error: wrong number of fields in line

For tab-separated TSV, specify options

$ csvlint -delimiter "\t" hoge.csv
Warning: not using defaults, may not validate CSV to RFC 4180
Record #23 has error: wrong number of fields in line

It seems you can’t pass data like the following.

yuis ASUS /mnt/c/_tmp/20190708221315$ csvlint - <<< "$( data-music-csv )"
file '-' does not exist

Therefore, to pass command output, do as follows.

$ data-music-csv > $TMPDIR/tmp.csv && csvlint -delimiter "\t" $TMPDIR/tmp.csv
Warning: not using defaults, may not validate CSV to RFC 4180
file is valid

Share this article

Shou Arisaka Oct 14, 2025

🔗 Copy Links