Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Donations to German parties
= Donations to German parties
data from here: https://github.com/pudo/kompromatron
== Sample Data Set
//setup
[source,cypher]
----
LOAD CSV WITH HEADERS FROM "https://raw.githubusercontent.com/pudo/kompromatron/master/data/spenden.csv" AS data
WITH data SKIP 0 LIMIT 375
MERGE (p:Party { name: data.partei_name, acronym: data.partei_acronym})
MERGE (d:Donor { name: data.spender_name})
MERGE (t:DonorType {theType: data.spender_typ})
CREATE d-[:DONATES_TO {value: toFloat(data.betrag_eur), year: toInt(data.jahr)}]->p
CREATE d-[:IS]->t
----
== Some Numbers
[source,cypher]
----
MATCH (d:Donor) RETURN count(*) AS NumberOfDonors
----
//table
[source,cypher]
----
MATCH (d:Party) RETURN d.name AS PartyName ORDER BY d.name
----
//table
[source,cypher]
----
MATCH (d:Donor)-[r:DONATES_TO]->(p:Party)
RETURN r.year AS Year, count(r.year) AS NumberOfRecords
ORDER BY r.year ASC
----
//table
[source,cypher]
----
MATCH (d:Donor)-[r:DONATES_TO]->(p:Party) RETURN p.name AS PartyName, round(sum(r.value)) as totalDonationsEur ORDER BY totalDonationsEur DESC
----
//table
== Top 10 Donors
[source,cypher]
----
MATCH (d:Donor)-[r:DONATES_TO]->(p:Party) RETURN d.name AS Donor, round(sum(r.value)) as totalDonationsInEUR ORDER BY totalDonationsInEUR DESC
LIMIT 10
----
//table
== Similiar parties by number of common donors
The more common donors two parties have the higher they appear in the table below.
[source,cypher]
----
MATCH path = (p1:Party)<-[r1:DONATES_TO]-()-[r2:DONATES_TO]->(p2:Party)
WHERE p1 <> p2 AND p1.name < p2.name
RETURN p1.name as Party1, p2.name as Party2, count(path) AS NoCommonDonors
ORDER BY NoCommonDonors DESC
----
//table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.