LDB
LDB

Reputation: 692

Neo4j LOAD CSV fails when multiline fields are encountered

neo4j-sh (?)$ USING PERIODIC COMMIT
> LOAD CSV WITH HEADERS FROM "file:/home/ubuntu/data/woka-data/woka-data.csv" AS row
> MERGE (woka:Woka           {woka_id:        row.woka_id, woka_title: row.woka_title});
IllegalMultilineFieldException: At file:/home/ubuntu/data/woka-data/woka-data.csv:834 - Multi-line fields are illegal in this context and so this might suggest that there's a field with a start quote, but a missing end quote.

My kernel version is 2.2.3 and the file is quite large:

-rwxr-xr-x 1 ubuntu ubuntu 2508218727 Jul 21 17:54 woka-data.csv

Any clue how to fix this?

I changed the order of the fields in the file and now the first error is reported for line 83. Here is this line:

97801322605720000000,eng,Addison Wesley Longman,,"Wri& Speakg at Work& Build Own CC& Mst
: Perils"

It is a new line before

: Perils

How to fix this?

This error seems to be specific to this kernel version. Before upgrading I used a similar file to import the same data having multiline fields and it worked.

What can I do now?

Upvotes: 3

Views: 1114

Answers (2)

LDB
LDB

Reputation: 692

The bug is still persistent in Kernel version 2.2.3 despite the claims that was fixed. I had to clean all data at the extraction time. I removed all characters that caused LOAD CSV to fail with reported error message or similar.

Upvotes: 3

Shreyas Chavan
Shreyas Chavan

Reputation: 1099

Found this gem in the source code. See if any rows(lines) in your csv have illegal quoting. Escape these and try again

public class IllegalMultilineFieldException extends FormatException
{
    public IllegalMultilineFieldException( SourceTraceability source )
    {
        super( source, "Multi-line fields are illegal in this context and so this might suggest that " + "there's a field with a start quote, but a missing end quote." );
    }
}

This was an issue before Neo4j 2.2.2. Bug report can be found here.

If youre using any version previous to 2.2.2 update it and it should work

I am using Kernel version Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.2.3

Upvotes: 1

Related Questions