Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rosstat Stats from Datafabric.cc
##
## Возвращает список учредителей ООО ДатаФабрик
##
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://104.155.96.199/blazegraph/sparql")
sparql.setQuery("""
PREFIX fts: <https://w3id.org/datafabric.cc/ontologies/fts#>
SELECT ?personInn ?equityPercentage ?person ?name WHERE {
?tax a fts:C44_LE_Tax_Accounting_Entity ;
fts:p82_refers_to_company ?leUri ;
fts:isLatestEntity "true"^^xsd:boolean ;
fts:p35_le_individual_tax_number ?latestInn .
?founder a fts:C54_Founder_Entity ;
fts:p82_refers_to_company ?leUri ;
fts:isLatestEntity "true"^^xsd:boolean ;
fts:p101_relates_to_person ?person ;
fts:p124_has_share/fts:p52_percentage_share ?equityPercentage .
?person a foaf:Person ;
fts:p75_ie_individual_tax_number ?personInn .
?person foaf:name ?name .
filter( langMatches(lang(?name),"") )
BIND ("5032284259" AS ?latestInn)
}
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
print(results)
for result in results["results"]["bindings"]:
for key, value in result.items():
print(key, ": ", result[key]["value"])
PREFIX fts: <https://w3id.org/datafabric.cc/ontologies/fts#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bds: <http://www.bigdata.com/rdf/search#>
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rosstat: <https://w3id.org/datafabric.cc/ontologies/rosstat#>
SELECT * {
?slice a qb:Slice ;
qb:sliceStructure rosstat:SliceByYearAndOrg ;
rosstat:refPeriod ?refPeriod ;
rosstat:refOrganization <http://example.com/legalentity/c33f2329-d7c4-5e6e-ac48-93ee544d752a> .
?slice qb:observation ?m1210 .
?m1210 a qb:Observation ;
qb:measureType rosstat:measure-1210 ;
rosstat:measure-1210 ?m1210value .
?slice qb:observation ?m1230 .
?m1230 a qb:Observation ;
qb:measureType rosstat:measure-1230 ;
rosstat:measure-1230 ?m1230value .
?slice qb:observation ?m1250 .
?m1250 a qb:Observation ;
qb:measureType rosstat:measure-1250 ;
rosstat:measure-1250 ?m1250value .
?slice qb:observation ?m1370 .
?m1370 a qb:Observation ;
qb:measureType rosstat:measure-1370 ;
rosstat:measure-1370 ?m1370value .
?slice qb:observation ?m1520 .
?m1520 a qb:Observation ;
qb:measureType rosstat:measure-1520 ;
rosstat:measure-1520 ?m1520value .
?slice qb:observation ?m2110 .
?m2110 a qb:Observation ;
qb:measureType rosstat:measure-2110 ;
rosstat:measure-2110 ?m2110value .
?slice qb:observation ?m2400 .
?m2400 a qb:Observation ;
qb:measureType rosstat:measure-2400 ;
rosstat:measure-2400 ?m2400value .
?slice qb:observation ?m2410 .
?m2410 a qb:Observation ;
qb:measureType rosstat:measure-2410 ;
rosstat:measure-2410 ?m2410value .
}
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.