title: How to import medium-sized CSV with a large number of nulls and columns into Neo4j
body: <p>I have to import an existing drug ontology into Neo4j. This ontology is stored in a CSV file; it comprises ~30000 lines and 192 columns per line (i.e. values). The thing is that, out of these 192 columns, the vast majority of them (~170) have null values in nearly all of the lines.</p>
  
  <p>The examples I have come across so far involve much simpler schemas (with 4 or 5 columns). In addition, I have not found any useful insights about how to deal with this type of models. However, I have found information regarding null values in general; nevertheless, as a newcomer to Neo4j, I am not sure what is the best way to get the data in the CSV file imported. As far as I know, these are the alternatives:</p>
  
  <ol>
  <li>Importation in stages. According to a webinar in Neo4j official webpage, I could first import the ID column and then, for each column "X" with nulls, filter the non-null values in the X column and dump both columns into a new CSV file. This last operation would lead to a Cypher code similar to the following (assuming all drugs are already imported):</li>
  </ol>
  
  <pre><code>USING PERIODIC COMMIT 10000
  LOAD CSV WITH HEADERS FROM "file:///Users/user/ontology_with .csv" AS line
  
  MATCH (drug:Drug {id: line.`Class ID`})
  MATCH (d:Drug {id: line.`X`})
  CREATE (drug)-[:ACTIVATES_DRUG]-&gt;(d)
  </code></pre>
  
  <ol start="2">
  <li>Using FOR EACH statement, which I believe simplifies the previous operation:</li>
  </ol>
  
  <pre><code>USING PERIODIC COMMIT 10000
  LOAD CSV WITH HEADERS FROM "file:///Users/user/ontology_with .csv" AS line
  FOREACH(n IN (CASE WHEN line.activates IS NULL THEN [] ELSE [1] END) |
      MERGE (drug:Drug {id: line.`Class ID`})
      CREATE (n)-[:ACTIVATES_DRUG]-&gt;(drug)
  )
  </code></pre>
  
  <ol start="3">
  <li>Using the batch importer. Although according to the size of the CSV (~30000 lines) this option should be dismissed, could it be beneficial considering the null values?. How would I have to cope with the null values if the best option turns out to be the batch importer?</li>
  </ol>
  
  <p>Taking into consideration the features of my original CSV file, particularly the massive number of columns, which way of importing the data into Neo4j would you suggest? I would appreciate the advice of experts or experienced users of Neo4j.</p>