Join the free virtual developer conference on knowledge graphs and AI. This year's themes are: applications, AI engineering, data intelligence, graphs, and architecture.
Hey, I just started learning neo4j and I'm facing one small error. Therefor, I want to CREATE a "table" from a csv file but my csv file containts back slashes and forward slashes. I know that these characters are escape characters but I tried to replace them during the CREATE process. This is my cypher:
LOAD CSV WITH HEADERS FROM "file:///comments.csv" AS row
CREATE (n:Comments)
SET n = row,
SET n.Content = CASE(row.Content) WHEN CONTAINS '\\' THEN replace(row.Content, '\\', '\\\\') ELSE row.Content
What I'm doing here is basically checking if row.Content contains '\' and if it does, replace it with double '\\'. However I get an error, the error says: Invalid input 'n': expected whitespace, comment, '{', node labels, MapLiteral, a parameter, a parameter (old syntax), a relationship pattern, '(', '.', '=' or "+=" (line 4, column 5 (offset: 94))
"SET n.Content = CASE(row.Content) WHEN CONTAINS '\' THEN replace(row.Content, '\', '\\') ELSE row.Content"
I googled this error but I didn't get any solution for my problem.
Thanks in advance
You have several syntax errors in your request , you forget the END at the end and the () can be removed in the CASE clause (doc):
LOAD CSV WITH HEADERS FROM "file:///comments.csv" AS row
CREATE (n:Comments)
SET n = row,
SET n.Content = CASE row.Content WHEN CONTAINS '\\' THEN replace(row.Content, '\\', '\\\\') ELSE row.Content END
I just edited my cypher but I still get the same error. Is it possible to replace a "" in a string?
Meanwhile I was googling and found out that "" can't be replaced with anything because it can't be recognized as a character.
I want to ask you because you're a certified professional :D
LOAD CSV WITH HEADERS FROM "file:///comments.csv" AS row
CREATE (n:Comments)
SET n = row
I get this error: there's a field starting with a quote and whereas it ends that quote there seems to be characters in that field after that ending quote. That isn't supported. This is what I read: 'same here, don’t know why… :",Daniel Nguyen,2009-06-30,1
Notice how the string ends without that :\ emoji.
This is a small part of the dataset, some fail (those that contain the backslash character in them, they throw an error) while the others get inserted without any problems.
Awkward but my neo4j.conf doesn't seem to contain this kind of path. This is my neo4j.conf:
I don't know if it matters but I use Linux Ubuntu 18.04
EDIT:
I just ran
CALL dbms.listConfig()
YIELD name, value
WHERE name STARTS WITH 'dbms.import'
RETURN name, value
ORDER BY name
LIMIT 3;
and got that dbms.import.csv.legacy_quote_escaping is set to true.