Created
September 9, 2016 12:47
-
-
Save Rembane/88c3ee416d5bc041c007eba06bf40e4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
from operator import itemgetter | |
# Javascript för att hämta data från val.sverok.se. | |
# Array.from(document.querySelectorAll('#content > div > table > tbody > tr td:nth-child(4)')).map(x => x.textContent).join(', ') | |
# Resulterande data. | |
orter = "Skövde , Helsingborg , Trollhättan , Ålberga , Upplands Väsby , Lövestad , , Göteborg , Nybro , Göteborg , , , Norrköping , Malmö , , , Hagfors , , Kalmar , , Kristinehamn , Linköping , Göteborg , Lindome , Krokom , , , Jönköping , , , , Göteborg , Lund , Göteborg , , , Göteborg , Malmö , Karlstad , Göteborg , , , Lund , Norrköping , Norrköping , Malmö , Jonkoping , , Malmö , , , Göteborg , Burträsk , Västervik , Visby , Sävar , Lund , Staffanstorp , Västerås , Göteborg , , Limhamn , Göteborg , Linköping , , , , Huskvarna , Eskilstuna , Norrköping , Karlskrona , Linköping , Tyringe , Luleå , Göteborg , Farsta , , Stockholm , , UMEÅ , Ålberga , Lund , , Skövde , , , Genarp , , Malmö , , Rydsgård , Karlshamn , Bara , , Västerås , Katrineholm , Lund , Göteborg , KRAMFORS , , Norrköping , Vikingstad , , Orsa , , , , , Linköping , Tidaholm , Göteborg , Järfälla , , Göteborg , , Kristinehamn , Stockholm , , Hallstahammar , , , Örbyhus , , , Kristinehamn , Lund , , Göteborg , , , , , , Göteborg , Göteborg , , , , , Umeå , Fårö , , , , , , , Kiruna , , Uppsala , Angered , , Visby , , Lund , , , , Röbäck , , , VÄSTERÅS , , Höör , , , , , Växjö " | |
# Sammanställ och printa i en fin text-tabell: | |
for (k,v) in sorted(Counter(filter(bool, [x.strip() for x in orter.split(',')])).items(), key=itemgetter(1, 0), reverse=True): | |
print('{:<15s}'.format(k), '{:>2d}'.format(v)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Göteborg 17 | |
Lund 7 | |
Norrköping 5 | |
Malmö 5 | |
Linköping 4 | |
Kristinehamn 3 | |
Ålberga 2 | |
Västerås 2 | |
Visby 2 | |
Stockholm 2 | |
Skövde 2 | |
Örbyhus 1 | |
Växjö 1 | |
Västervik 1 | |
VÄSTERÅS 1 | |
Vikingstad 1 | |
Uppsala 1 | |
Upplands Väsby 1 | |
Umeå 1 | |
UMEÅ 1 | |
Tyringe 1 | |
Trollhättan 1 | |
Tidaholm 1 | |
Sävar 1 | |
Staffanstorp 1 | |
Röbäck 1 | |
Rydsgård 1 | |
Orsa 1 | |
Nybro 1 | |
Lövestad 1 | |
Luleå 1 | |
Lindome 1 | |
Limhamn 1 | |
Krokom 1 | |
Kiruna 1 | |
Katrineholm 1 | |
Karlstad 1 | |
Karlskrona 1 | |
Karlshamn 1 | |
Kalmar 1 | |
KRAMFORS 1 | |
Jönköping 1 | |
Järfälla 1 | |
Jonkoping 1 | |
Höör 1 | |
Huskvarna 1 | |
Helsingborg 1 | |
Hallstahammar 1 | |
Hagfors 1 | |
Genarp 1 | |
Fårö 1 | |
Farsta 1 | |
Eskilstuna 1 | |
Burträsk 1 | |
Bara 1 | |
Angered 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment