1

When running neo4j-shell with tools from https://github.com/jexp/neo4j-shell-tools it will not load my graphml file, validated on http://validator.w3.org/check.

Neo4j runs on Ubuntu under KDE with OpenJDK IcedTea 2.3.9

Here is the command and message:

neo4j-sh (0)$ import-graphml -i /home/larsj/Prosjekt/neograf/bigram_graph.xml -t bigram
GraphML-Import file /home/larsj/Prosjekt/neograf/bigram_graph.xml 
rel-type bigram batch-size 40000 use disk-cache false
0. 100%: nodes = 1 rels = 0 properties = 0 time 6 ms
null

How can it be made to work? Here is a snippet of my graphml file:

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">

<key id = "form0" for = "node" attr.name = "label" attr.type = "string"/>
<key id = "freq0" for = "all" attr.name = "frequency" attr.type = "int"/>
<key id = "mi0" for = "edge" attr.name = "mi" attr.type = "float"/>
<key id = "label0" for = "edge" attr.name = "label" attr.type = "string">
   <default>bigram</default>
</key><graph id="nb.no/bigrams" edgedefault="directed">    <node id="1512655">
    <data key = "form0">barn</data>
    <data key = "freq0">526136</data>
</node>
<node id="1781558">
    <data key = "form0">fattige</data>
    <data key = "freq0">49089</data>
</node>
<edge  source = "2305969" target = "3070510">
    <data key = "freq0">86421</data>
    <data key = "mi0">71.57629973392675</data>
</edge>
<edge  source = "3070510" target = "3070510">
    <data key = "freq0">22</data>
    <data key = "mi0">-9.818479721124337</data>
</edge>

Fresbee
  • 13
  • 3
Lars GJ
  • 356
  • 2
  • 8
  • The graphml file loads easily into gephi (gephi.org) and displays there, so it should be all right. – Lars GJ Sep 28 '13 at 10:19

1 Answers1

0

One pitfall of neo4j shell-tools' import-graphml command is ensuring that every key has a key id before the graph tags of your document. Any node or edge that has a key that is not defined in the key id section will not be imported by shell-tools. Not seeing your entire file, it is possible that are node/edge properties that do not have a defined XML key ID.

To check for any key ID mismatches, use the XML plug-in for Notepad++ called XML Tools. Once installed, go to Plugins > XML Tools > Validate Now. It will show a dialog box with any key IDs that are not defined.

The import command will work, as long as every property in the "data" fields has a key ID defined before the "graph" tags. Type the following in the Neo4j shell-tools console:

import-graphml -i [name of input graphml file]

If you want to include these key IDs when exporting from Neo4j to GraphML, use this command in the shell-tools console. It's useful when dumping your database and then loading it back into Neo4j's format:

$ export-graphml -o [name of output graphml file] -t

Fresbee
  • 13
  • 3