This file contains hidden or 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
# Part of BORIS BOARD Project | |
# Visit http://www.borisboard.com for more details | |
# | |
# By Coolgarif Tech Ltd | |
# Author: Richie Barter | |
# 21 Aug 2013 | |
# Sample script for parsing a CSV into JSON for data vis | |
# Underlying DataSet | |
# Available here: http://data.london.gov.uk/datastore/package/street-trees-borough |
This file contains hidden or 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
if __name__ == '__main__': | |
app.debug = True | |
app.run() |
This file contains hidden or 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 neo4jrestclient.client import GraphDatabase | |
from neo4jrestclient.constants import RAW | |
from neo4jrestclient.client import Node | |
from urlparse import urlparse | |
import re, json | |
from flask import Flask, Response, json, jsonify, request, Blueprint, render_template | |
app = Flask(__name__) |
This file contains hidden or 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
$ python hydraGraph.py | |
# Navigate to this URL | |
http://127.0.0.1:5000/_api/hydraGraph?callback=khjsdbkjn | |
# FINAL JSON END POINT RESPONSE!! | |
# (Note the callback wrapper at the front!) |
This file contains hidden or 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
callbackWrapper = callbackArguments + "(" + result + ")" | |
resp = Response(callbackWrapper, status = 200, mimetype = 'application/json') | |
return resp |
This file contains hidden or 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
result = { | |
'nodes' : nodes, | |
'rels' : rels} | |
result = json.dumps(result) |
This file contains hidden or 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
for rel in querySquenceObject: | |
r = rel.pop() | |
start = r.get('start') | |
end = r.get('end') | |
start = urlparse(start) | |
end = urlparse(end) | |
startNode = doRegEX(start) | |
endNode = doRegEX(end) |
This file contains hidden or 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
q = "START n=node(*) MATCH (n)-[r]->() RETURN r" | |
params = {} | |
querySquenceObject = db.query(q, params=params, returns=RAW) |
This file contains hidden or 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
nodeJSON.append(createNodeJSON(name, uid, description)) | |
def createNodeJSON(name, uid, description): | |
JSONObject = { | |
'name': name, | |
'id' : uid, | |
'description' : description | |
} | |
return JSONObject |
This file contains hidden or 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
def doRegEX(urlString): | |
regex = re.compile("([^/]*)$") | |
stripedURLComponent = regex.search(urlString.path) | |
return stripedURLComponent.group(0) |
NewerOlder