csvkit 学习和使用 (三) csvjoin csvstack

来源:互联网 发布:软件开发行业分类 编辑:程序博客网 时间:2024/06/05 02:43

The following is referred to the documentation of csvkit which is available at : http://csvkit.readthedocs.org/

It's sorted with my own understanding, and any questions and advices are welcome.

The source code of csvkit is available on github:  https://github.com/onyxfish/csvkit


(1)  Join two datasets together by some rules, for example both two datasets have a column called "fips", then :

csvjoin -c fips data.csv acs2012_5yr_population.csv > joined.csv

It's similar to the commands in MySQL, but it can drive you to where you want to quickly.


(2) Stack two datasets together

 csvstack ne_1033_data.csv ks_1033_data.csv > region.csv

As an option, "-g" can be added into the command to tell which file the row come from.


(3) csvsql & sql2csv

To be continued...




0 0
原创粉丝点击