changeset 52:763b5d29fa5e

add int type to ismi_id attribute in neo4j csv import file.
author casties
date Fri, 17 Mar 2017 17:51:18 +0100
parents 5a633e875490
children 1f160e595167
files importFromOpenMind/importer/model2neo4j_import.py
diffstat 1 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/importFromOpenMind/importer/model2neo4j_import.py	Fri Mar 03 20:11:06 2017 +0100
+++ b/importFromOpenMind/importer/model2neo4j_import.py	Fri Mar 17 17:51:18 2017 +0100
@@ -7,9 +7,6 @@
 # metworkx graph file
 input_fn = 'ismi_graph.gpickle'
 
-# label added to all nodes
-project_label = '_ismi'
-
 # neo4j import file
 node_import_fn = "neo4j-nodes.csv"
 relation_import_fn = "neo4j-relations.csv"
@@ -44,6 +41,10 @@
         attrs = nx_graph.node[node_id]
         # save all attribute names
         for att in attrs.keys():
+            # add type to ismi_id
+            if att == 'ismi_id':
+                att = 'ismi_id:int'
+                
             ismi_fields.add(att)
         
     return list(ismi_fields)
@@ -61,6 +62,10 @@
         attrs = nx_graph.edge[nx_src][nx_tar][0].copy()
         # save all attribute names
         for att in attrs.keys():
+            # add type to ismi_id
+            if att == 'ismi_id':
+                att = 'ismi_id:int'
+                
             ismi_fields.add(att)
         
     return list(ismi_fields)
@@ -77,12 +82,19 @@
         ntype = attrs[node_type_attribute]
         # add as label
         attrs[':LABEL'] = ntype
+        
         # get ismi_id
         ismi_id = attrs['ismi_id']
         # add ismi_id as node id
         attrs[':ID'] = ismi_id
+        
+        # change ismi_id key to add type
+        attrs['ismi_id:int'] = ismi_id
+        del attrs['ismi_id']
+        
         # write row
         node_writer.writerow(attrs)
+        
         # save node id
         n4j_nodes[ismi_id] = ismi_id
 
@@ -124,6 +136,10 @@
         attrs[':START_ID'] = src_id
         attrs[':END_ID'] = tar_id
 
+        # change ismi_id key to add type
+        attrs['ismi_id:int'] = attrs['ismi_id']
+        del attrs['ismi_id']
+
         # write row
         relation_writer.writerow(attrs)