cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Import csv or api data in python using apoc.periodic.iterate

Peter_Lian
Node Clone

Just few questions since I can not find any issue about them. The following is my query that can work in Neo4j server 

 

CALL apoc.periodic.iterate("CALL apoc.load.csv('file:///import/data') YIELD map AS row  RETURN  row",

'CREATE (computer:Computer{computer:coalesce(row.Computer,"No Computer")})',

{batchSize:10000, iterateList:true, parallel:true})

 

Can this query work in Python, i.e., can apoc.periodic.iterate and apoc.load.csv both work in Python?

 

Moreover, if I import my data into Python (for example, panda-dataframe), can apoc.periodic.iterate work in Python without the help of apoc.load.csv? 

 

Appreciate.

1 REPLY 1

I don’t see why it wouldn’t work as long as you have the apoc plug-in installed your server. The python driver will send the query to the server for execution. 

you could convert the data frame data into a list of dictionaries and pass the list as a parameter to perodic.iterate. The first query in perodic.iterate would consist of an ‘unwind’ followed by a ‘return’, resulting in rows of maps, one from each row of the data frame. The second query in perodic.iterate would process each map in batches.