Skip to content

Instantly share code, notes, and snippets.

@wilt00
Created June 10, 2017 20:48
Show Gist options
  • Save wilt00/e6def9c751d53b18253871c84ecb47c8 to your computer and use it in GitHub Desktop.
Save wilt00/e6def9c751d53b18253871c84ecb47c8 to your computer and use it in GitHub Desktop.
$ curl -LO http://burntsushi.net/stuff/worldcitiespop.csv
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 144M 100 144M 0 0 5440k 0 0:00:27 0:00:27 --:--:-- 5743k
$ xsv headers worldcitiespop.csv
1 Country
2 City
3 AccentCity
4 Region
5 Population
6 Latitude
7 Longitude
$ xsv stats worldcitiespop.csv --everything | xsv table
field type sum min max min_length max_length mean stddev median mode cardinality
Country Unicode ad zw 2 2 cn 234
City Unicode bab el ahmar Þykkvibaer 1 91 san jose 2351892
AccentCity Unicode Bâb el Ahmar ïn Bou Chella 1 91 San Antonio 2375760
Region Unicode 00 Z9 0 2 13 04 397
Population Integer 2289584999 7 31480498 0 8 47719.570633597126 302885.5592040396 10779 28754
Latitude Float 86294096.37312101 -54.933333 82.483333 1 12 27.188165808468785 21.95261384912504 32.4972221 51.15 1038349
Longitude Float 117718483.57958724 -179.9833333 180 1 14 37.08885989656418 63.223010459241635 35.28 23.8 1167162
$ xsv index worldcitiespop.csv
$ xsv stats worldcitiespop.csv --everything | xsv table
^C
$ time xsv stats worldcitiespop.csv --everything
^C
real 0m52.223s
user 0m8.266s
sys 0m2.781s
$ ls -l
total 172864
-rw-rw-rw- 1 wt wt 151492068 Jun 10 15:25 worldcitiespop.csv
-rw-rw-rw- 1 wt wt 25391680 Jun 10 15:28 worldcitiespop.csv.idx
$ rm worldcitiespop.csv.idx
$ time xsv stats worldcitiespop.csv --everything
field,type,sum,min,max,min_length,max_length,mean,stddev,median,mode,cardinality
Country,Unicode,,ad,zw,2,2,,,,cn,234
City,Unicode,, bab el ahmar,Þykkvibaer,1,91,,,,san jose,2351892
AccentCity,Unicode,, Bâb el Ahmar,ïn Bou Chella,1,91,,,,San Antonio,2375760
Region,Unicode,,00,Z9,0,2,,,13,04,397
Population,Integer,2289584999,7,31480498,0,8,47719.570633597126,302885.5592040396,10779,,28754
Latitude,Float,86294096.37312101,-54.933333,82.483333,1,12,27.188165808468785,21.95261384912504,32.4972221,51.15,1038349
Longitude,Float,117718483.57958724,-179.9833333,180,1,14,37.08885989656418,63.223010459241635,35.28,23.8,1167162
real 0m10.812s
user 0m17.281s
sys 0m2.203s
$ xsv index worldcitiespop.csv
$ time xsv count worldcitiespop.csv
3173958
real 0m0.025s
user 0m0.000s
sys 0m0.016s
$ time xsv slice worldcitiespop.csv -s 3173948
Country,City,AccentCity,Region,Population,Latitude,Longitude
zw,zibalonkwe,Zibalonkwe,06,,-19.8333333,27.4666667
zw,zibunkululu,Zibunkululu,06,,-19.6666667,27.6166667
zw,ziga,Ziga,06,,-19.2166667,27.4833333
zw,zikamanas village,Zikamanas Village,00,,-18.2166667,27.95
zw,zimbabwe,Zimbabwe,07,,-20.2666667,30.9166667
zw,zimre park,Zimre Park,04,,-17.8661111,31.2136111
zw,ziyakamanas,Ziyakamanas,00,,-18.2166667,27.95
zw,zizalisari,Zizalisari,04,,-17.7588889,31.0105556
zw,zuzumba,Zuzumba,06,,-20.0333333,27.9333333
zw,zvishavane,Zvishavane,07,79876,-20.3333333,30.0333333
real 0m0.028s
user 0m0.000s
sys 0m0.031s
$ time xsv stats worldcitiespop.csv --everything
^C
real 2m37.513s
user 0m8.391s
sys 0m2.594s
$ rm worldcitiespop.csv.idx
$ time xsv stats worldcitiespop.csv --everything
field,type,sum,min,max,min_length,max_length,mean,stddev,median,mode,cardinality
Country,Unicode,,ad,zw,2,2,,,,cn,234
City,Unicode,, bab el ahmar,Þykkvibaer,1,91,,,,san jose,2351892
AccentCity,Unicode,, Bâb el Ahmar,ïn Bou Chella,1,91,,,,San Antonio,2375760
Region,Unicode,,00,Z9,0,2,,,13,04,397
Population,Integer,2289584999,7,31480498,0,8,47719.570633597126,302885.5592040396,10779,,28754
Latitude,Float,86294096.37312101,-54.933333,82.483333,1,12,27.188165808468785,21.95261384912504,32.4972221,51.15,1038349
Longitude,Float,117718483.57958724,-179.9833333,180,1,14,37.08885989656418,63.223010459241635,35.28,23.8,1167162
real 0m12.040s
user 0m18.125s
sys 0m2.313s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment