cvlin (síblɪŋ : しぶりん) is CSV Lint tool. CsV LINt.
- Write rule file in toml format
id = "A0[0-9]"
name = ".*"
point = "^\\d+$"
- Prepare CSV file you want to lint
# id,name,point
A01,Shibuya Rin,100
A02,,200
- Check if your CSV is valid (i.e. your CSV satisfies each regexp or not)
# specify rule file with -r or --rule option
$ cvlin -r rule.toml subject.csv
Valid.
- If your CSV is invalid (see ID of 2nd row):
# id,name,point
A01,Shibuya Rin,100
B02,,200
- you get error message
$ cvlin -r rule.toml invalid.csv
Invalid. ( line: 1, column: 0, value: B02, rules: A0[0-9] )
Just download, unzip and place it in $PATH directory. For example, on Linux:
VERSION=v1.0.0; sudo wget https://github.com/megane42/cvlin/releases/download/$VERSION/cvlin-linux-amd64 -O /usr/local/bin/cvlin
sudo chmod +x /usr/local/bin/cvlin
-
Rule file is written in toml format.
- The left-hand side is the name of column. This is just for documentation.
- The right-hand side is the regexp which the correspond column should satisfy.
-
Regexp is read as "string literal", not as "raw string literal". So you must escape all special chars.
- good:
\\d
- bad:
\d
- good:
- For further portability, you can embed default rule file into the binary.
- Embedded default rule is used when you invoke cvlin without -r option.
- How to:
- Prepare go build environment
go get -u github.com/jteeuwen/go-bindata/...
go get github.com/megane42/cvlin/
- Write your rule in
default_rules.toml
cd $GOPATH/src/github.com/megane42/cvlin
go-bindata --pkg cvlin -o cvlin/bindata.go default_rules.toml
go test github.com/megane42/cvlin/...
- Fork (https://github.com/megane42/cvlin/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
go test ./...
command and confirm that it passes - Create a new Pull Request
go install
sh ./build.sh
git tag $(cvlin -v)
ghr $(cvlin -v) ./bin
- MIT