仅提取邮政编码和 lsoa 代码 - sparkql [英] extracting only postcode and lsoa code - sparkql
本文介绍了仅提取邮政编码和 lsoa 代码 - sparkql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一些 sparkql 来提取邮政编码数据和行进 lsoa 代码.到目前为止,当我只想要最后一个单元时,我所拥有的提取了邮政编码和 lsoa 代码的所有 url.请问如何只获取最后一个元素?
I am trying to write some sparkql to extract postcode data and marching lsoa codes. what I have so far extracts all the url for both the postcodes and lsoa codes, when I would like just the last unit. How do i get just the last elements please?
query <- "PREFIX pc: <http://data.ordnancesurvey.co.uk/ontology/postcode/>
PREFIX geo: <http://opendatacommunities.org/def/geography#>
SELECT * WHERE {
?postcodeUnit
a pc:PostcodeUnit;
geo:lsoa ?lsoa .
}
limit 10"
endpoint <- "http://opendatacommunities.org/sparql"
resultList <- SPARQL(endpoint,query)
head(resultList)
我也担心当我开始工作时,R studio 会超时,我需要从 Web 服务器运行它吗?请
I am also concerned when i get this working, R studio will time out, do i need to run this from a web server? please
提前致谢
推荐答案
如果 URI 的生成方式是标准的,你可以把结果转成字符串,然后只取需要的部分:
If the way URIs are generated is standard, you can just turn the results into strings and then take only the part that is needed:
PREFIX pc: <http://data.ordnancesurvey.co.uk/ontology/postcode/>
PREFIX geo: <http://opendatacommunities.org/def/geography#>
SELECT ?postcode ?lsoa
WHERE {
?URI_postcodeUnit
a pc:PostcodeUnit;
geo:lsoa ?URI_lsoa .
BIND (STRAFTER((STR(?URI_postcodeUnit)),"postcodeunit/") as ?postcode)
BIND (STRAFTER((STR(?URI_lsoa)),"lsoa/") as ?lsoa)
}
limit 10
这篇关于仅提取邮政编码和 lsoa 代码 - sparkql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文