Livedata from nrw-election

http://www.aachener-zeitung.de/zva/karlo/regionAC_LTWNRW/

the political map of our region in nrw (germany) liveupdated during election …

6 Likes

Looks great! I also like the ability to compare 2017 with 2012 :thumbsup:

thx :slight_smile: unfortunately the wrong party succeed :frowning:

1 Like

Good work Hans. Shame about the result. :slight_smile:

Very cool! Can you share how you’re reading/updating live data for this doc?

@Daniel

for a hint check the Lounge :wink:

1 Like

Great

for @all
the data is provided by csv-files.

@DBear provided a solution better then mine to read out the data and directly parse it it to json within php.

sample:

$url="http://wahlen.regioit.de/AC/LW12/05334002/html5/Landtagswahl_NRW3.csv";
$file = fopen($url,'r');
$all_rows = array();
$header = null;
while ( ($row = fgetcsv($file, 1200, ";") ) !== FALSE ) {
	if ($header === null) {
        $header = $row;
        continue;
    }
    $all_rows[] = array_combine($header, $row);
}
$json = json_encode($all_rows);
print_r($json);
fclose($file); 

i just did a curl to receive a string and parsed with js:

$csvUrl = $_POST['csvFile'];


$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL, $csvUrl); 
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'; 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_VERBOSE, true); 
curl_setopt($ch, CURLOPT_USERAGENT, $agent); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); //time out of 15 seconds
$data = curl_exec($ch);


curl_close($ch);

regionAC_LTWNRW.hype.zip (160.7 KB)

3 Likes

That is great!!
I will need to reference this in 2018 here in the states :slight_smile:

2 Likes

in preview of the next election here in germany i did a small update showing some additional barcharts corresponding to the hovered mapsection, click will be a deeplink to our extended resultspage …

http://www.aachener-zeitung.de/zva/karlo/regionAC_LTWNRW/

3 Likes

Very nice!! That is really great work!