Sociomaps: Add some csv generation tools
[gostyle.git] / sociomaps / pca2csv
blob3ebc5f1f675ac3ae5626e13c58ec233a093e1b22
2 cat <<EOT
3 Column type,,0colt,Number (non-test),Number (non-test),Number (non-test),Number (non-test),Number (non-test),Number (non-test)
4 Scores,,0scor,Percentiles,Percentiles,Percentiles,Percentiles,Percentiles,Percentiles,Percentiles
5 Range Min,,0rmin,,,,,,
6 Range Max,,0rmax,,,,,,
7 Missings,,0mis,Constant,Constant,Constant,Constant,Constant,Constant
8 Replace,,0rep,50,50,50,50,50,2000
9 Weight,,0wei,1,0.4,0.2,0.1,0.1,0.1
10 ,FILTER,NAME,PCA1+2,PCA1,PCA2,PCA3,PCA4,PCA5
11 EOT
12 cat ../pca.data  | perl -nle 'chomp; my @z = split(/ /); $p{$z[0]}->[$z[1]-1] = ($z[2]+1.0)*50; END {foreach (keys %p){print join(",","",1,$_, (0.45*$p{$_}->[0] + 0.19*$p{$_}->[1]), (@{$p{$_}}));}}' | cut -d , -f 1-9 | sort -t, -k 3 | tr _ ' '
13 }>player-pca.csv
14 join -t , -j 3 -o 1.3,1.1,1.2,1.4,1.5,1.6,1.7,1.8,2.4,2.5,2.6,2.7,2.8,2.9 player-style.csv player-pca.csv | sed 's/^0[^,]*//; s/^\([^,]*\),\([^,]*,[^,]*\)/\2,\1/' | tee players.csv