Livedata from nrw-election

(Hans-Gerd Claßen) #1

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


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

(Hans-Gerd Claßen) #3

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


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


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



for a hint check the Lounge :wink:



(Hans-Gerd Claßen) #8

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.


$file = fopen($url,'r');
$all_rows = array();
$header = null;
while ( ($row = fgetcsv($file, 1200, ";") ) !== FALSE ) {
	if ($header === null) {
        $header = $row;
    $all_rows[] = array_combine($header, $row);
$json = json_encode($all_rows);

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); (160.7 KB)

(Nick ) #9

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

(Hans-Gerd Claßen) #10

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 …

(Nick ) #11

Very nice!! That is really great work!