#cd $HOME/tm/HighwayData/hwy_data/_systems/ #or like wherever
systems=$(tail -n +2 ../../systems.csv | grep -v '^#' | cut -f1 -d';')
region_counts=$(for s in $systems; do printf "%03i;$s\n" $(tail -n +2 $s.csv | cut -f2 -d';' | sort | uniq | wc -l); done | sort)
for region_count in $(echo "$region_counts" | cut -f1 -d';' | sort | uniq); do
system_count=$(echo "$region_counts" | grep -c "^$region_count;")
if [ $system_count = 1 ]
then s_plural=''
e_plural='s'
else s_plural='s'
e_plural=''
fi
printf "%i system%s exist%s in %i region" \
$system_count \
"$s_plural" \
"$e_plural" \
$(echo $region_count | sed 's~^0*~~')
if [ $region_count -gt 1 ]
then echo -n s
else echo -n ' each'
fi
if [ $system_count -le 5 ]
then echo -n ": "; echo ": $region_counts" | grep "^$region_count;" | cut -f2 -d';' | tr '\n' ',' | sed -e 's~,~, ~g' -e 's~, $~\n~'
else echo
fi
done
360 systems exist in 1 region each
75 systems exist in 2 regions
16 systems exist in 3 regions
5 systems exist in 4 regions: asiaho, ausn, ausstr, cism, fraidfd77
3 systems exist in 5 regions: afrea, ausm, cannf
3 systems exist in 7 regions: asimo, ausa, mexed
1 system exists in 8 regions: asim
1 system exists in 10 regions: cantch
3 systems exist in 12 regions: fraa, fran, index
3 systems exist in 13 regions: afrrtr, mexsf, usaif
1 system exists in 14 regions: indnh
2 systems exist in 15 regions: espa, usaush
2 systems exist in 16 regions: deua, eurtr
1 system exists in 17 regions: espn
1 system exists in 19 regions: deub
1 system exists in 23 regions: afrtah
3 systems exist in 25 regions: asiah, usaib, usasf
1 system exists in 30 regions: chng
2 systems exist in 31 regions: mexd, usanp
2 systems exist in 32 regions: eursf, mexf
1 system exists in 48 regions: usausb (MA has none)
1 system exists in 49 regions: usaus
1 system exists in 50 regions: asiahp
1 system exists in 52 regions: usai
1 system exists in 92 regions: eure
Mean: 2.778 regions per system
Median: 1