kanion
kanion

Reputation: 117

Neo4j import csv to database

I want to import Publications from csv to neo4j. And make Query which will select all authors which are authors of publication or at least one author.

I have csv file in format Author,Publication

Sanjeev Saxena,Parallel Integer Sorting and Simulation Amongst CRCW Models.
Hans-Ulrich Simon,Pattern Matching in Trees and Nets.
Nathan Goodman,NP-complete Problems Simplified on Tree Schemas.
Oded Shmueli,NP-complete Problems Simplified on Tree Schemas.
Norbert Blum,On the Power of Chain Rules in Context Free Grammars.
Arnold Sch,rpern der Charakteristik 2.
nhage,rpern der Charakteristik 2.
Juha Honkala,A characterization of rational D0L power series.
Chua-Huang Huang,The Derivation of Systolic Implementations of Programs.
Christian Lengauer,The Derivation of Systolic Implementations of Programs.

I used this query:

USING PERIODIC COMMIT
LOAD CSV FROM 'file:/home/kanion/studia/bazy/clean.csv' AS line
CREATE (:Publikacja { author: line[1], title: line[2]})

and after import i have:

https://i.sstatic.net/QzYOe.jpg

So i think that authors isn't imported? How to deal with that?

Upvotes: 0

Views: 156

Answers (1)

Christophe Willemsen
Christophe Willemsen

Reputation: 20175

In most if not all programming languages, the first key of an array is 0 so it should be line[0] for the author and line[1] for the title

USING PERIODIC COMMIT
LOAD CSV FROM 'file:/home/kanion/studia/bazy/clean.csv' AS line
CREATE (:Publikacja { author: line[0], title: line[1]})

Upvotes: 2

Related Questions