简体   繁体   中英

Neo4j handling date time values as different nodes

I am importing a CSV file with financial data in it. How do I model the graph in such a way that the YEAR, MONTH, and DAY values are shown as three different nodes.

Created_Date,TransactionId
2017-10-17 12:37:00.287,1 
2018-03-15 02:00:48.930,2

I checked a few of documentation, and all of them helped me form just a single node.

LOAD CSV with headers FROM 'file:///filename.csv' as row
WITH apoc.date.parse(row.Created_Date, "ms", "yyyy-MM-dd HH:MM:SS") AS ms
MERGE (d:Date {date: date(datetime({epochmillis: ms}))})

The structure I am looking for is more of TransId - Year - Month - Date . How do I manage to get this with the datetime library?

A better approach would be to parse the DateTime values and store them as properties to a Node.

LOAD CSV with headers FROM 'file:///filename.csv' as row
WITH apoc.date.fields(LEFT(row.Created_Date, 10), 'yyyy-MM-dd') AS val
MERGE (d:Date {year: val.years, month: val.months, day: val.days})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM