neo4j specify data-type during import from csv

4.1k views Asked by At

is there a way to tell the neo4j the type of the value when importing? for example, does the neo4j knows if "2015-0104T10:33:44" is a date or string?

thanks!

4

There are 4 answers

0
Stefan Armbruster On BEST ANSWER

Neo4j uses java primitive types, Strings or arrays of those for property values. There is no date type. So "2015-0104T10:33:44" is a String.

Cypher provides couple of functions for type conversion like toFloat, toInt, ... that might help you here.

Most folks store millis since epoch for date and time information. However Cypher does not yet have a function to convert a string to millis, so you're doing this probably in a pre-processing step in your csv files.

1
josyanne On

There is a date Type in Neo4j : If you are importing your CSV file using the Neo4j data import tool (see the link https://neo4j.com/docs/operations-manual/current/tools/import/file-header-format/) you could specify dateTime with a specific format for a column of your file

Also see : https://neo4j.com/docs/developer-manual/current/cypher/syntax/temporal/

0
Christophe Willemsen On

There is no DATE type in Neo4j.

However you can cast values to 3 possible types in Neo4j :

  1. toFloat(value)
  2. toInt(value)
  3. toString(value)
0
Torben Koch Pløen On

I have, to be honest, no idea how it was back in 2015 when the question was asked, but now, at least, it is possible to use any one of the cypher functions when importing using LOAD CSV.

This means that, just as you can use toInt(...), you can also use e.g. date(row.date) (where row.date might contain a value like "2018-07-01") in the ON MATCH and ON CREATE parts of the LOAD CSV statement.

See https://neo4j.com/docs/developer-manual/current/cypher/functions/ for details about functions.

As to what data types are available in Neo4j the picture probably has changed quite a bit since 2015, too. Looking at https://neo4j.com/docs/developer-manual/current/cypher/syntax/values/ suggests that temporal types like: Date, Time, LocalTime, DateTime, LocalDateTime and Duration are now available.