This file contains 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
import rdflib | |
# from io import StringIO | |
# import xml.etree.ElementTree as etree | |
#builtGraph is where I'm going to accumulate triples that I've scraped | |
builtGraph=rdflib.Graph() | |
#addedGraph contains triples that I got from a particular GeoNames RDF file | |
addedGraph=rdflib.Graph() |
This file contains 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
# script from https://github.com/rhasan/sw/blob/master/genames/convert2ntriples.py | |
# with some hacks to make it work for Python 3 | |
# This script will take genames rdf dump available here http://download.geonames.org/all-geonames-rdf.zip | |
# and convert each triples to N-Triple seralization. | |
# The dump has one rdf document per toponym on every line of the file. | |
# The produced N-Triples will be written in geonames.nt file. The final geonames.nt file is approximately 13.21GB | |
#!/usr/bin/python | |
import rdflib | |
fo = open("geonames.nt", "wb") |