cancel
Showing results for 
Search instead for 
Did you mean: 

Loading a JSON object via parameter that is composed by json objects, delimited by "\n"

bmalbusca
Node Clone

Hello, I have a Json file that is composed by a json object per line (as a result of pandas.to_json() )

{json obj 1}
{json obj 2}
{json obj 3}
{json obj 4}

The problem is that when I send this object through a parameter, using the Neo4j python driver, I get a new line char "\n" on the other side, separating the objects inside the list:

[{json obj 1}\n{json obj 2}\n{json obj 3}\n{json obj 4}]

Is there a way to iterate this with cypher? I tested by importing the files, and it worked. Now, the GOAL is using a parameter but I'm not getting there.
I'm sharing the test code ,for importing the file, that works:

QUERY_STATION_TEST = """CALL apoc.load.json("file:///stations.json")
                        YIELD value
                        MERGE (n:Station{SNIRH:value.SNIRH})
                        SET n += value
                        RETURN count(n)
"""
1 ACCEPTED SOLUTION

bmalbusca
Node Clone

SOLUTION

Instead using pandas.to_json() I solved the problem using pandas._to_dict(). It already does the job properly

View solution in original post

1 REPLY 1

bmalbusca
Node Clone

SOLUTION

Instead using pandas.to_json() I solved the problem using pandas._to_dict(). It already does the job properly

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.