How does Dgraph import files other than RDF files, such as json or CSV?


(Enze) #1

How do I import a json file if I convert the CSV to json?I’m a newbie, I’m really sorry but maybe my question is a little bit simple。


(Daniel Mai) #2

You can run a mutation to insert data from JSON format: https://docs.dgraph.io/mutations/#json-mutation-format


(Enze) #3

emmm… I want to insert a local json document ? For example, a local document that contains several json data


(Enze) #4

just like load csv in cypher?
-H ‘X-Dgraph-MutationType: json’ -H ‘X-Dgraph-CommitNow: true’
This statement appears to read only one line of data, right?What I want to do is read in a local file?


(Enze) #5

I think if you can add a feature which is importing a local file like.json or .CSV file.Or a plug-in which turning them into RDF/ n-quad files will make it much easier for beginners to learn.


(Daniel Mai) #6

If you want to read a local file with cURL that contains a mutation you can do so by passing the filename prefixed with an @-sign. This is a feature of cURL that treats files as input. e.g.,

curl -H 'X-Dgraph-MutationType: json' -H 'Dgraph-CommitNow: true' localhost:8080/mutate -d @mutationFile.json