Capture a running sum while loading data via Load CSV

29 views
Skip to first unread message

Phil M

unread,
Aug 12, 2017, 8:01:23 PM8/12/17
to Neo4j
I am importing data using load CSV. My script has a Merge and "On Match set". When I find a match, I would like to add the value from the CSV row to a running total property. When the process ends the final value will be the sum of previous values for each match. This possible during the load process?

 

Michael Hunger

unread,
Aug 13, 2017, 9:45:16 PM8/13/17
to ne...@googlegroups.com
Do you have an example for your query? It's not totally clear what you're asking for.

On Sun, Aug 13, 2017 at 1:01 AM, Phil M <pmere...@gmail.com> wrote:
I am importing data using load CSV. My script has a Merge and "On Match set". When I find a match, I would like to add the value from the CSV row to a running total property. When the process ends the final value will be the sum of previous values for each match. This possible during the load process?

 

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phil M

unread,
Aug 15, 2017, 12:47:01 AM8/15/17
to Neo4j, michael...@neo4j.com
I want to capture total sales by customer in Neo4j. This data is currently stored in a sales table and a sales order line table. I use a left outer join to join the two tables and then I export this to CSV. As I load this data into Neo4j I want the data summed at the sales order level so it would be great if I could take the values at the line item level rolled up to the sales order level. I do not care about the detail. Make sense?




On Sunday, August 13, 2017 at 9:45:16 PM UTC-4, Michael Hunger wrote:
Do you have an example for your query? It's not totally clear what you're asking for.
On Sun, Aug 13, 2017 at 1:01 AM, Phil M <pmere...@gmail.com> wrote:
I am importing data using load CSV. My script has a Merge and "On Match set". When I find a match, I would like to add the value from the CSV row to a running total property. When the process ends the final value will be the sum of previous values for each match. This possible during the load process?

 

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.

Kamal Murthy

unread,
Aug 15, 2017, 7:06:34 PM8/15/17
to Neo4j
Hi Phil,

I had similar situations before and I tried many ways but nothing worked. I think LOADCSV creates nodes and relationships while looping through the data file, but they get committed to the database only at a later stage (Michael correct me if am wrong)

Actually, in your situation add a coloumn to your export file and store the sum of the line item value like amount and use this when you create a sales order node as a property. You will see same values for the last column for each custid and salesordid, but use it once when you create salesorder node. This is how I solved my cases.

Second option is to create a separate .csv file with custid, salesordid, total amount. After running your existing .csv file run the second file, use MATCH/MERGE to add the totamount.

-Kamal
Reply all
Reply to author
Forward
0 new messages