title: Neo4j CSV Import: Remove/Filter specific values during import
body: <p>I import data via CSV upload with py2neo. The following script reads each column and it's rows of the file and push to Neo4j. File includes thousands of rows under four columns. Some columns includes values like "n/a", "undefined", "null", "unknown" and blank cells. When the script iterates the columns and rows, It pushes all data also to the db.</p>
  
  <p>I want, when the script reads "n/a" or "undefined", "null"... it should ignore these data and doesn't push the db.</p>
  
  <pre><code>result_data = "./Excel2CSV/result.csv"
  graph.cypher.execute("CREATE CONSTRAINT ON (result:RESULT) ASSERT result.id IS UNIQUE")
  with open(result_data, 'r+') as in_file:
      reader = csv.reader(in_file, delimiter=';')
      next(reader, None)
      batch = graph.cypher.begin()
      try:
          i = 0;
          j = 0;
          for row in reader:
              if row:
                  f_name = strip(row[0])
                  l_name = strip(row[1])
                  nickname = strip(row[2]
                  text = strip(row[3])
                  result = strip(row[4])
                  query = """
                      merge (person:Person {f_name:{a}, l_name{b}, nickname{c}})
                      merge (text:TEXT {value:{d}})
                      merge (Result:RESULT {value:{e}})
                      merge (person)-[:WROTE]-&gt;(text)
                      merge (person)-[:REPLIED]-&gt;(result)
                  """
                  batch.append(query, {"a": f_name, "b": l_name, "c": nickname, "d": text, "e": result})
                  i += 1
                  j += 1
              batch.process()
  </code></pre>
  
  <h2><strong>EDIT REGARDING THE BELOW ANSWER:</strong></h2>
  
  <p>For example I am creating a node called "person" and this node has 3 properties "f_name" coming from {a} column, "l_name" coming from {b} column and "nickname" come from {c} column. Assume each of the columns have the above "unwanted" values. I created the node with the first "f_name" property:</p>
  
  <pre><code>WITH CASE WHEN {a} IN ["n/a", "undefined", "null"] THEN "" ELSE {a} END AS x
  OPTIONAL MATCH (person:Person { f_name: x })
  </code></pre>
  
  <p>and before passing to </p>
  
  <p><code>WITH CASE WHEN text IS NULL THEN [x] ELSE [] END AS todo
  FOREACH (i IN todo | CREATE (person:Person { l_name: i })),</code></p>
  
  <p>I need to apply same filtering to remove unwanted values for "l_name" and "nickname" properties. And I think I should define the new properties to append the new properties to "person" node.</p>