简体   繁体   English

Neo4j 将日期时间值作为不同节点处理

[英]Neo4j handling date time values as different nodes

I am importing a CSV file with financial data in it.我正在导入一个包含财务数据的 CSV 文件。 How do I model the graph in such a way that the YEAR, MONTH, and DAY values are shown as three different nodes.如何以 YEAR、MONTH 和 DAY 值显示为三个不同节点的方式对图形进行建模。

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 .我正在寻找的结构更多是TransId - Year - Month - Date How do I manage to get this with the datetime library?我如何设法通过 datetime 库获得它?

A better approach would be to parse the DateTime values and store them as properties to a Node.更好的方法是解析 DateTime 值并将它们作为属性存储到节点。

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})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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