title: Create column in OpenRefine using a logic test on an existing column?
body: <p>I have an original data set with over 4,500 row entries representing land transactions. One of the existing columns is "Place," and in each cell value I've put the locality name usually as <code>Some Neighborhood</code>, but sometimes when there is a place I don't know, I'll add additional info from the notary records, e.g., <code>Some Neighborhood, Some County</code> or even as <code>Some Neighborhood, Some County (nicknamed)</code>.</p>
  
  <p>I want to create two new columns using the info from this one column. The first column would contain the upper-level administrative division, and the second column the administrative division above that -- kinda like zooming out.</p>
  
  <p>I think I would need to create a new column based on existing column using a sort of logical test or if-if-if- test where I can enumerate the values of <code>Some Neighborhood</code> that belong to <code>County 1</code> or <code>County 2</code> or <code>City 1</code>, etc. Then, based on this new column, I'd create another that would have <code>State 1</code>, <code>State 2</code>, etc., presumably using the same sort of test.</p>
  
  <p>How would I write this using regular expressions in Open Refine GREL? How can I string together multiple <em>possible</em> values that are found in the cells? I tried using <code>cells</code> and <code>value.contains</code> but I do not know how to string together multiples like this.</p>
  
  <p>So again to recap, I want to script a way to create a new column that contains new cell values based on a column of existing values, something like</p>
  
  <p>"<em>if</em> <code>Street1</code>,<code>Street2</code>, <code>Street5,</code> <em>but not</em> <code>Street3</code>, or <code>Street4</code>, <em>then</em> <code>County1</code>"</p>
  
  <p>OR</p>
  
  <p>"<em>if</em> <code>Street1</code> or <code>Street2</code> or <code>Street5,</code> <em>then</em> <code>County1</code> <em>AND THEN IF</em> <code>Street3</code> or <code>Street4</code> <em>then</em> <code>County2</code>"</p>
  
  <hr>
  
  <p>EDIT:
  Here's some of the data:</p>
  
  <pre><code>land sale   0.350   carreau 350 gourdes Bullet
  land sale   1.000   carreau 700 gourdes Campèche
  land sale   0.200   carreau 220 gourdes Bremont
  land sale   0.500   carreau 150 gourdes Pierrette
  land sale   5.000   carreau 225 gourdes Lagenivrée
  land sale   0.125   carreau 200 gourdes Bullet
  land sale   1.000   carreau 300 gourdes Tozin
  land sale   0.125   carreau 100 gourdes Dufort
  land sale   0.250   carreau 135 gourdes Charitte, Savann Brute
  land sale   0.500   carreau 300 gourdes Ravines des Roches
  land sale   0.500   carreau 80  gourdes Isidore (Nègre Libre)
  land sale   0.500   carreau 215 gourdes Nordette (Boures)
  land sale   0.250   carreau 200 gourdes Bullet (Morne Montègue)
  </code></pre>
  
  <p>And here's an example of the expected result with two new columns, let's say "Commune" and "Section":</p>
  
  <pre><code>land sale   0.350   carreau 350 gourdes Limonade    Bwadlans    Bullet
  land sale   1.000   carreau 700 gourdes Limonade    Bwadlans    Campèche
  land sale   0.200   carreau 220 gourdes Limonade    Bwadlans    Bremont
  land sale   0.500   carreau 150 gourdes Limonade    Roucou      Pierrette
  land sale   5.000   carreau 225 gourdes Limonade    Roucou      Lagenivrée
  land sale   0.125   carreau 200 gourdes Limonade    Bwadlans    Bullet
  land sale   1.000   carreau 300 gourdes Quart_Mor   Sablé       Tozin
  land sale   0.125   carreau 100 gourdes Limonade    Bwadlans    Dufort
  land sale   0.250   carreau 135 gourdes Limonade    Bwadlans    Charitte, Savann Brute
  land sale   0.500   carreau 300 gourdes Limonade    Bwadlans    Ravines des Roches
  land sale   0.500   carreau 80  gourdes Limonade    Bwadlans    Isidore (Nègre Libre)
  land sale   0.500   carreau 215 gourdes Limonade    Bwadlans    Nordette (Boures)
  land sale   0.250   carreau 200 gourdes Limonade    Bwadlans    Bullet (Morne Montègue)
  </code></pre>