I am currently working in a doctoral program, and I'm interested in Py2neo, so I use it to perform some experiments using social graphs. However, I got into problems with beginners. Excuse me for asking these simple questions.
I got an xml dataset containing jornal publication data, I converted it to a csv table, there are about 700 entries, and each entry consists of four fields: date, title, keywords, author. So my first question is how to program the chart from this table. I thought about writing a python script that loops the csv table, reads fields for each row and columns, and writes them to nodes. ++++++++++++++++++++++++++++++++++++++++++++++++ Code ++++ +++++++++++++++++++++++++++++++++++++++++
#!/usr/bin/env python # import csv from py2neo import neo4j, cypher from py2neo import node, rel # calls database service of Neo4j # graph_db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/") # # Create nodes and relationships from a csv table # since it a csv table, a reader must be invoked ifile = open('testeout5_cp.csv', "rb") reader = csv.reader(ifile) # clear database graph_db.clear() rownum = 0 for row in reader: colnum = 0 for col in row: titulo, autor, rel = graph_db.create( {"titulo": col[1]}, {"autor": col[3]}, (1, "eh_autor_de", 0) ) print(titulo, autor) rownum += 1 ifile.close()
================ I got this output (Fragment): Python 2.7.5 (default, August 22, 2013, 09:31:58) [GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on aires2, Standard
(Node('http://localhost:7474/db/data/node/10392'), Node('http://localhost:7474/db/data /node/10393')) (Node('http://localhost:7474/db/data/node/10394'), Node('http://localhost:7474/db/data/node/10395')) (Node('http://localhost:7474/db/data/node/10396'), Node('http://localhost:7474/db/data/node/10397')) (Node('http://localhost:7474/db/data/node/10398'), Node('http://localhost:7474/db/data/node/10399')) (Node('http://localhost:7474/db/data/node/10400'), Node('http://localhost:7474/db/data/node/10401')) (Node('http://localhost:7474/db/data/node/10402'), Node('http://localhost:7474/db/data/node/10403')) (Node('http://localhost:7474/db/data/node/10404'), Node('http://localhost:7474/db/data/node/10405'))
========= What is wrong?
source share