26 February 2016

info

  1. csvkit is a suite of command-line tools

         for converting to and workding with csv
    
  2. github repo

  3. document

why csvkit

  1. convert

    1. excel to csv

       $ in2csv data.xls > data.csv
      
    2. json to csv

       $ in2csv data.json > data.csv
      
    3. csv to json

       $ csvjson data.csv > data.json
      
    4. postgresql

       # import into postgresql
       csvsql --db postgresql:///db --insert data.csv
      
       # export from postgresql
       sql2csv --db postgresql:///db --query "select * from data" > data.csv
      
  2. print

    1. column names

       $ csvcut -n data.csv
      
    2. select subset of columns

       $ csvcut -c col_a,col_c data.csv > new.csv
      
    3. reorder columns

       $ csvcut -c col_c,col_a data.csv > new.csv
      
  3. find

    1. rows matching cells

       $ csvgrep -c phone_number -r "555-555-\d{4}" data.csv > matching.csv
      
  4. summary statistics

         $ csvstat data.csv
    
  5. query with sql

         $ csvsql --query "select name from data where age > 30" data.csv > old_folks.csv
    

usage

  1. input

    1. in2csv

    2. sql2csv

  2. processing

    1. csvclean

    2. csvcut

    3. csvgrep

    4. csvjoin

    5. csvsort

    6. csvstack

  3. output and analysis

    1. csvformat

    2. csvjson

    3. csvlook

    4. csvpy

    5. csvsql

    6. csvstat



blog comments powered by Disqus