Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Possible implementation that casts rather than infers type? #8

Open
dhimmel opened this issue Oct 6, 2020 · 1 comment
Open

Possible implementation that casts rather than infers type? #8

dhimmel opened this issue Oct 6, 2020 · 1 comment

Comments

@dhimmel
Copy link

dhimmel commented Oct 6, 2020

I saw this repo mentioned in RDFLib/sparqlwrapper#125. Very cool. Here's the heart of the conversion:

sparql.setReturnFormat(CSV)
results = sparql.query().convert()
_csv = StringIO(results.decode('utf-8'))
return pd.read_csv(_csv, sep=",")

The SPARQLWrapper.Wrapper.QueryResult object is converted to a CSV string, and then loaded into pandas.

I am guessing this works well most of the time! But it does discard type information and then lets Pandas infer types upon reading the CSV. This makes me a bit nervous.

Have you considered at all whether a type-casting rather than a type-inferring implementation is possible?

Also related is RDFLib/sparqlwrapper#160. Ideally this would be part of RDFLib/sparqlwrapper to reduce the dependencies required to use SPARQL in Python, but this library seems the furthest ahead at providing user-friendly outputs and API.

@WolfgangFahl
Copy link

https://github.com/WolfgangFahl/pyLoDStorage has a proper python type handling mechanism.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants