Skip to content

Instantly share code, notes, and snippets.

@n-kb
n-kb / owl2django.py
Last active December 19, 2015 18:28
This simple script roughly converts an OWL file created by Protégé into a models.py file to be used with Neo4Django. Comments/improvements very welcome!
from lxml import etree
# This string will contain the models.py file
modelsContents = "from neo4django.db import models\n\n"
# Enter the name of the OWL file to parse
# The relationships in the file should always start with has...
owlFile = "ontology.owl"
# Gives the ontology URI. Only needed for documentation purposes
# Loops through all zoom levels
for zoom_level in range(4,13):
#Loops through all cities
for city in cities:
#Finds out which tile the city is in
X_city, Y_city = deg2num(city_lat, city_lng, zoom_level)
# Computes the 16 tiles around the city
# Loops through all zoom levels
for zoom_level in range(4,13):
# Computes all tiles for the whole world
for X in range (0, int(math.pow(2, zoom_level))):
for Y in range (0, int(math.pow(2, zoom_level))):
# Finds the bounds of each tile
N_tile, W_tile = num2deg(X, Y, zoom_level)
S_tile, E_tile = num2deg(X + 1, Y + 1, zoom_level)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
import urllib2
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as image
import pylab
from PIL import Image
This file has been truncated, but you can view the full file.
{
"log": {
"comment": "",
"creator": {
"comment": "",
"name": "BrowserMob Proxy",
"version": "2.1.4"
},
"entries": [
{
@n-kb
n-kb / scrape.py
Created February 13, 2020 20:31
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import csv, time
import os.path
browser = webdriver.Chrome()
for year in range(2013, 2020):
for month in range(1,13):