Skip to content

Instantly share code, notes, and snippets.

@beauvais
beauvais / iced-tea
Created December 9, 2011 16:45
foodista cocktail
@prefix dcterm: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ns1: <http://linkedrecipes.org/schema/> .
<http://data.kasabi.com/dataset/foodista/recipe/3QWJPYHF> a <http://linkedrecipes.org/schema/Recipe>;
ns1:ingredient <http://data.kasabi.com/dataset/foodista/food/DSVFF8DN>,
<http://data.kasabi.com/dataset/foodista/food/FBPQ4456>,
<http://data.kasabi.com/dataset/foodista/food/HSBJL3L8>,
<http://data.kasabi.com/dataset/foodista/food/JGYY7HZX>,
<http://data.kasabi.com/dataset/foodista/food/N5VJMXRC>,
@beauvais
beauvais / sparql.txt
Created October 28, 2011 13:09
SPARQL to find winning parties
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX def: <http://data.kasabi.com/dataset/european-election-results/def/>
PREFIX cube: <http://purl.org/linked-data/cube#dataset>
Select ?label
WHERE {
?subject rdfs:label ?label ;
?p <http://data.kasabi.com/dataset/european-election-results/2009/political_groups/seats_won> .
}
@beauvais
beauvais / csv.py
Created October 20, 2011 23:16
Python for tagging in CSV
# assign variable to a csv file read by csv.reader
csvFile = csv.reader(open('/Users/Zach/Desktop/survey.csv', 'rb'), delimiter=',')
# identify header row
header = next(csvFile)
# loop rows in csv file, and identify variables for fields
for row in csvFile:
if row[20] < 0:
continue
@beauvais
beauvais / error.py
Created October 18, 2011 20:40
print row range
csvFile = csv.reader(open('survey.csv', 'rb'), delimiter=',')
header = next(csvFile)
for row in csvFile:
devStatus = row[4]
address = row[14]
commercial = row[12]
# note = row[20]
industry = row[10]
if row[20]:
@beauvais
beauvais / csv-chop
Created October 18, 2011 18:35
CSV Chopping
csvFile = csv.reader(open('thing.csv', 'rU'), delimiter=',')
header = next(csvFile)
for row in csvFile:
devStatus = row[4]
address = row[14]
commercial = row[12]
comment = row[20]
industry = row[10]
@beauvais
beauvais / gist:1253325
Created September 30, 2011 10:00
SPARQL for Flemish Art
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX gac: <http://data.kasabi.com/dataset/government-art-collection/schema/>
SELECT ?work ?name ?image ?page WHERE {
?subject skos:prefLabel "Flemish School".
?work dct:subject ?subject;