Exemplo n.º 1
0
 def getMetadataFromCkan(self, uri):
     from csv2rdf.ckan.resource import Resource
     resource = Resource('')
     try:
         resource = resource.search_by_uri(uri)
         logger.info("Resource %s - SUCCESS" % uri.encode('utf-8'))
     except BaseException as e:
         logger.error("Cannot load resource: %s - %s" %
                      (uri.encode('utf-8'), str(e)))
         resource = []
     return resource
Exemplo n.º 2
0
    def _getResourceMetadata(self, resourceId):
        resource = Resource(resourceId)
        resource.init()
        
        mapping = Mapping(resourceId)
        headers = mapping.get_mapping_headers()
        headers = self._concatHeaders(headers)

        tf = TabularFile(resourceId)
        csvDataframe = tf.get_csv_data()
        refine = Refine(resourceId)
        table = refine.structure_by_cols(csvDataframe)
        table = self._concatTable(table)

        package = Package(resource.package_name)
        return (resource, package, headers, table)
Exemplo n.º 3
0
 def get_resource(self):
     resource = Resource(self.resource_id)
     resource.init()
     return resource
Exemplo n.º 4
0
import RDF
from csv2rdf.ckan.resource import Resource
from csv2rdf.ckan.package import Package

resource_id = "69f7e7ad-1efa-4f0c-8f0b-71949f55a743"

if __name__ == "__main__":
    res = Resource(resource_id)
    res.init()
    package_name = res.request_package_name()
    package = Package(package_name)
    package_metadata = package.get_metadata()
    model = RDF.Model()
    parser = RDF.Parser()
    parser.parse_string_into_model(model, package_metadata, "http://localhost/")
    
    #title is label
    title_predicate = "http://purl.org/dc/terms/title"
    qs = RDF.Statement(subject = None, 
                       predicate = RDF.Node(uri_string = title_predicate), 
                       object = None)
    for statement in model.find_statements(qs): 
        title_statement = statement
        break
    #description is comment
    description_predicate = "http://purl.org/dc/terms/description"
    qs = RDF.Statement(subject = None, 
                       predicate = RDF.Node(uri_string = description_predicate), 
                       object = None)
    for statement in model.find_statements(qs): 
        description_statement = statement
Exemplo n.º 5
0
from csv2rdf.ckan.resource import Resource

resource = Resource('')
f = open('iswc-datasets.csv')
for line in f:
    resource_uri = line.split(',')[1].strip()
    res = resource.search_by_uri(resource_uri)
    print res['id']

f.close()