Loading rdf into stardog database

I want to resolve this exception on loading rdf into database at

connection.add().io().format(RDFFormat.N3).stream(new FileInputStream(“c:/2Salles1.rdf”));

com.complexible.stardog.StardogException: There was a fatal failure during preparation of fe180f82-1d44-4df0-b6b0-caeb5ec45e61 org.openrdf.rio.RDFParseException: IRI included an unencoded space: ‘32’ [line 1]
at com.complexible.stardog.protocols.http.client.BaseHttpClient.checkResponseCode(BaseHttpClient.java:433)
at com.complexible.stardog.protocols.http.client.BaseHttpClient.execute(BaseHttpClient.java:304)
at com.complexible.stardog.protocols.http.client.HttpClientImpl.commit(HttpClientImpl.java:565)
at com.complexible.stardog.protocols.http.client.HttpClientImpl.commit(HttpClientImpl.java:93)
at com.complexible.stardog.api.impl.SPECConnection._commit(SPECConnection.java:261)
at com.complexible.stardog.api.impl.AbstractConnection.commit(AbstractConnection.java:207)
at com.complexible.stardog.api.impl.DelegatingConnection.commit(DelegatingConnection.java:111)
at test.star.dog.testSarDog.main(testSarDog.java:93)

someone has guided me to set DatabaseOptions.STRICT_PARSING
i.e., Control whether Stardog parses RDF strictly (true, the default) or loosely (false)

kindly help

You have an encoding issue with one of your URLs. You have a space where it should be urlencoded as %20.

You can find the offending lines with

grep '<.* .*>' "c:/2Salles1.rdf"

and replace the space with %20 by hand or use sed. I see you’re using windows so you’ll have to use Cygwin or the equivalent in powershell or whatever it is Windows people use to do something like that.

I have not fixed it. But when I upload it by web interface, it uploads the triple store from c:/2Salles1.rdf perfectly. But with java api it does not do so. I dont see any white spaces in URLs

I'm not sure if this will help, but Windows uses backslashes in file paths, so chances are good that you actually want new FileInputStream("c:\\2Salles1.rdf"). Especially since you say it loads fine in the webconsole, it seems like the problem could be in the java command itself.

thanks for your advice, but it has not worked. It just tried it but again the same error

Is your data set large/sensitive, or would you be able to share it here?

rdf file is not allowed to upload

I apologize for not noticing this earlier. You are attempting to upload an RDF/XML file, but the format you are passing in to the IO object is that of N-Triples. Instead of RDFFormat.N3, try RDFFormat.RDFXML.

1 Like

thanks dear stephen, it works very well.

thanks once again for your time and precious advice