RDF import doesn't support comments (#)
According to the spec, https://www.w3.org/TR/2014/REC-n-triples-20140225/, lines with comments start with #. It should be noted that you are allowed to place comments at the end of a line too.
I've chosen an example from DBPedia which is small and still fails.
I've provided a few commands decompress and then recompress as a gz for the bulk loader.
error:
2017/01/13 10:56:58 embedflag.go:35: ICU is working fine!
Processing homepages_en.ttl.gz
2017/01/13 10:57:04 main.go:73: While parsing RDF: Invalid input: # at lexText
wget http://downloads.dbpedia.org/2016-04/core-i18n/en/mappingbased_objects_disjoint_domain_en.ttl.bz2
bzip2 -d mappingbased_objects_disjoint_domain_en.ttl.bz2
gzip < mappingbased_objects_disjoint_domain_en.ttl > mappingbased_objects_disjoint_domain_en.ttl.gz
A short sed script should fix strange input in intrim.
sed -e 's/#.*$//' < inp >outp
Does # need escaping here?
I'd argue that # is apart of the spec and should just be supported/ignored. Additionally, even if you remove #'s with a sed, there are additional crashes. The dbpedia system uses # in their URIs. Check the following example:
wget http://downloads.dbpedia.org/2016-04/core-i18n/en/infobox_properties_en.ttl.bz2
bzip2 -d infobox_properties_en.ttl.bz2
sed -e 's/#.*$//' < infobox_properties_en.ttl > infobox_properties_en_fixed.ttl
gzip < infobox_properties_en_fixed.ttl > infobox_properties_en_fixed.gz
dgraphloader -r infobox_properties_en_fixed.gz
2017/01/15 19:38:34 embedflag.go:35: ICU is working fine!
Processing infobox_properties_en_fixed.ttl.gz
2017/01/15 19:38:34 main.go:73: While parsing RDF: Invalid end of input. Input: []
EDIT: Looks like it left an empty space on the first line which caused the above error. Removing it still has other issues.
2017/01/15 19:53:54 embedflag.go:35: ICU is working fine!
Processing infobox_properties_en_fixed_2.ttl.gz
2017/01/15 19:53:54 main.go:73: While parsing RDF: Unexpected end of subject
Trying to verify the issue, but it looks like it removed a # and everything after it in a subject
I'm using this dataset
wget http://downloads.dbpedia.org/2016-04/core-i18n/en/infobox_properties_en.ttl.bz2
bzip2 -d infobox_properties_en.ttl.bz2
gzip < infobox_properties_en.ttl > infobox_properties_en.ttl.gz
And I'm running the following command
dgraphloader -r infobox_properties_en.ttl.gz
The output is the following error
Processing infobox_properties_en.ttl.gz
2017/01/19 12:48:37 main.go:76: While parsing RDF: parsing time "-0063-09-23" as "2006": cannot parse "-0063-09-23" as "2006"
I build the version of dgraph from
On branch bugfix/rdf-comments
using ./build.sh
@clanstyles i grep the lines that include "-0063-09-23" as you mentioned,
<http://dbpedia.org/resource/Augustus> <http://dbpedia.org/property/birthDate> "-0063-09-23"^^<http://www.w3.org/2001/XMLSchema#date> .
<http://dbpedia.org/resource/Early_life_of_Augustus> <http://dbpedia.org/property/birthDate> "-0063-09-23"^^<http://www.w3.org/2001/XMLSchema#date> .
While schema#date should take the form as yyyy-mm-dd. I thought those two lines are invalid input ?
Besides, once an invalid line is encountered, we should not stop there, instead, we should continue reading the rest lines ?
It looks like it's the first line, which is a comment.
# started 2016-06-27T22:44:42Z
<http://dbpedia.org/resource/Actrius> <http://dbpedia.org/property/name> "Actresses"@en .
Dug into it more, removed the comment line and tried to reprocess it. I'm assuming the following records are what are triggering it.
<http://dbpedia.org/resource/Augustus> <http://dbpedia.org/property/birthDate> "-0063-09-23"^^<http://www.w3.org/2001/XMLSchema#date> .
<http://dbpedia.org/resource/Early_life_of_Augustus> <http://dbpedia.org/property/birthDate> "-0063-09-23"^^<http://www.w3.org/2001/XMLSchema#date> .
zcat /home/dgraph/infobox_properties_en.ttl.gz | grep -0063-09-23
@clanstyles agree with you about those two lines. As they seems to be in incorrect format, refuse them is fine. Therefore, please remove those two lines to continue ?