Another RDFLib question: is there a way to take SPARQL results and push them to a CSV? I've looked through documentation and it looks possible but I'm still a bit puzzled. (My colleagues want Excel sheets. I know. I know. 馃檭)
if you do something like
for row in results:
dict_results = row.asdict()the dict_results will be in rdflib variables so like URIRef, Literal, etc so you may need to iterate through the dict and do .toPython() but it might be worth trying and seeing what happens if you write that dict_results to a csv. I haven't tried myself
Glad to hear it!
i dont know much about rdflib, but you can get sparql results as csv from most endpoints. rdflib might be able to execute the query and get the results as csv w/o you having to transform them
Thank you, Michael G.. Working from an endpoint isn't an option unfortunately. That's why I was hoping RDFLib would do it without much issue. I'll definitely use one when I can.
that's not my point. rdflib likely already has code to both read and write results as csv. in which case, you can just pass a result to the csv writer built into the library.
Ok. I see. Thank you.
unless you need a custom csv format, it'll be way easier to just re-use what's in rdflib than to DIY
Leia D. I recorded a <10min video walkthrough addressing your questions about printing RDFLib SPARQL results and exporting to CSV. I hope it's helpful to you. https://www.youtube.com/watch?v=FD_xFFotvxU