info
-
csvkit is a suite of command-line tools
for converting to and workding with csv
why csvkit
-
convert
-
excel to csv
$ in2csv data.xls > data.csv
-
json to csv
$ in2csv data.json > data.csv
-
csv to json
$ csvjson data.csv > data.json
-
postgresql
# import into postgresql csvsql --db postgresql:///db --insert data.csv # export from postgresql sql2csv --db postgresql:///db --query "select * from data" > data.csv
-
-
print
-
column names
$ csvcut -n data.csv
-
select subset of columns
$ csvcut -c col_a,col_c data.csv > new.csv
-
reorder columns
$ csvcut -c col_c,col_a data.csv > new.csv
-
-
find
-
rows matching cells
$ csvgrep -c phone_number -r "555-555-\d{4}" data.csv > matching.csv
-
-
summary statistics
$ csvstat data.csv
-
query with sql
$ csvsql --query "select name from data where age > 30" data.csv > old_folks.csv