LOAD CSV
LOAD CSV
is a built-in Cypher instruction that can be used with the filename of a CSV file, and Cypher instructions to play for each line of the CSV file.
Note
CSV stands for comma-separated value. Normally, each column of the file is separated by a comma, which was not a good idea. It is far more common to see the semicolon character used as a separator, which is a better choice, but my personal choice is to use the Unix pipe character | as a separator. The first line may be a list of headers. CSV is text; you do not need a spreadsheet to open CSV files.
Here is a simple example taken from the Neo4j website. It will load data from a URL and, for each line of this source, will run the CREATE
command. I have highlighted the points that I'll discuss in this chapter:
LOADCSVWITHHEADERSFROM'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists-with-headers.csv'ASlineCREATE(:Artist{name:line.Name,year:toInt(line.Year)})
LOAD CSV WITH HEADERS
means that the first line of the CSV input will...