Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:13:29+00:00 2026-06-02T11:13:29+00:00

I am trying to filter a turtle file using pyrdf with sparql. But I

  • 0

I am trying to filter a turtle file using pyrdf with sparql. But I noticed that sparql queries lose information over the context of the elements. I would like then to re-print the result of the query as a turtle file, is it possible to do this without manually scanning all the subfields of the element? We have data about locations formatted like this:

:pt0001
     vcard:category "Poste e Telegrafi"
    ; vcard:fn "Ufficio Bologna 1"
    ; vcard:extended-address "Via Cairoli 9, Bologna BO, Italy"
    ; vcard:latitude "44.504192"
    ; vcard:longitude "11.338661"
    ; vcard:tel "051 243425"
    ; vcard:fax "051 244459"
    ; cs:opening "Mon, Tue, Wed, Thu, Fri: 0800-1330. Sat: 0800-1230."
    ; cs:closing "01-01, 01-06, P, LA, 04-25, 05-01, 06-02, 08-15, 11-01, 12-08, 12-25, 12-26: .".

For example we want only locations that have a name (fn).
Thanks for any tip you find…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:13:31+00:00Added an answer on June 2, 2026 at 11:13 am

    To get back all locations which have a name, you could do something simple like:

    SELECT DISTINCT ?location
    WHERE { 
       ?location vcard:fn [].
    }
    

    This will give you back back the identifier (:pt0001 in your example), but of course the query can be adapted to return all the property values as well.

    (Edit I added additional examples based on your clarification, I think this is what you’re after)

    Like so:

    SELECT ?location ?prop ?value
    WHERE { 
       ?location vcard:fn [];
                 ?prop ?value .
    } ORDER BY ?location
    

    The result of this query will be a table of results of the form:

    ?location    ?prop           ?value
    :pt0001      vcard:category  "Poste e Telegrafi"
    :pt0001      vcard:name      "Ufficio Bologna 1"
    :pt0001      vcard:tel       "051 243425"
    (etc...)   
    

    Or, as yet another alternative, you can explicitly formulate your query to get specific property values for each location:

    SELECT ?location ?name ?cat ?tel
    WHERE { 
       ?location vcard:fn ?name ;
                 vcard:category ?cat ;
                 vcard:tel ?tel .
    } ORDER BY ?location
    

    which will give you back a result table of the form:

    ?location ?name               ?cat                ?tel
    :pt0001   "Ufficio Bologna 1" "Poste e Telegrafi" "051 243425"
    

    Take your pick.

    The trick with SPARQL queries is to think in terms of triples. Your data contains subject-predicate-object triples, SPARQL queries formulate patterns over those triples.

    As a further remark: I see you are thinking about re-printing the result of the query as turtle. In that case, a CONSTRUCT query might be what you’re after. While the result of a SELECT query (as shown above) is a table structure, the result of a CONSTRUCT query is a collection of RDF triples:

     CONSTRUCT { ?subject ?predicate ?object }
     WHERE { 
       ?subject ?predicate ?object ;
                vcard:fn [] 
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to filter an XML file using XPath. The XPath that I'm using
I'm trying to filter a Spring configuration file using Maven filtering. My POM is
Hi i was trying to filter a large of text file using Regex.Split with
I'm currently trying to filter a text-file which contains words that are separated with
Im trying to filter rows based on a column say c1 that contains boolean
I'm trying to filter some XML in JavaScript using E4X and have some specific
I'm trying to filter by a list of values using the criteria API. I
I am trying to filter for an object that has a Title field, and
I'm trying to filter webserver log files using grep. I need to output all
I'm trying to filter out some garbage text from a string with regex but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.