O'Reilly logo

Learning Neo4j 3.x - Second Edition by Rik Van Bruggen, Jérôme Baton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting the first line of a CSV file

Getting the first line of a CSV file proves very useful to write the core of the Cypher queries. Why use a spreadsheet editor to copy/paste the first line when you can do it on a command prompt? This is even more useful if the file is huge and takes time to open.

On a Linux machine, try the following:

head -1 theBigHugeCSVFile.csv

If you want to create a Cypher file, try with the usual redirection:

head -1 theBigHugeCSVFile.csv > myFantasticImport.cyp

Now, you can open the .cyp file in your preferred text editor and replace the field separator with, at minimum, a line jump (\n), the equal sign, the name of the variable you want to use (such as line), and a dot.

This way, you have a block of all the fields ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required