Livedata from nrw-election


(Hans-Gerd Claßen) #1

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

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


#2

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:


#4

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


#5

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


#6

@Daniel

for a hint check the Lounge :wink:


#7

Great


(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.

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)


(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 …

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


(Nick ) #11

Very nice!! That is really great work!