title: Case/if-else statement to create new column in new csv
body: <p>I'm trying to do a case/if-else statement on a CSV file (e.g., <code>myfile.csv</code>) that analyzes a column, then creates a new column in a new csv (e.g., <code>myfile_new.csv</code>).</p>
  
  <p>The source data (<code>myfile.csv</code>) looks like this: </p>
  
  <pre><code>unique_id,variable1,variable2
  1,,C
  2,1,
  3,,A
  4,,B
  5,1,
  </code></pre>
  
  <p>I'm trying to do two transformations:</p>
  
  <ul>
  <li>For the second field, if the input file has any data in the field, have it be 1, otherwise 0.</li>
  <li>The third field is flattened into three fields. If the input file has an <code>A</code> in the third field, the third output field has <code>1</code>, and <code>0</code> otherwise; the same for <code>B</code> and <code>C</code> and the fourth/fifth field in the output file.</li>
  </ul>
  
  <p>I want the result (<code>myfile_new.csv</code>) to look like this: </p>
  
  <pre><code>unique_id,variable1,variable2_A,variable2_B,variable2_C
  1,0,0,0,1
  2,1,0,0,0
  3,0,1,0,0
  4,0,0,1,0
  5,1,0,0,0
  </code></pre>
  
  <p>I'm trying to do the equivalent of this in <code>SQL</code> </p>
  
  <pre><code>select unique_id, 
  case when len(variable1)&gt;0 then 1 else 0 as variable1, 
  case when variable2 = 'A' then 1 else 0 end as variable2_A, 
  case when variable2 = 'B' then 1 else 0 end as variable2_B, 
  case when variable2 = 'C' then 1 else 0 end as variable2_C, ... 
  </code></pre>
  
  <p>I'm open to whatever, but CSV files will be 500GB - 1TB in size so it needs to work with that size file.</p>