title: CSV file data manipulation
body: <p>I have many rows containing 'input' as substring under column 'Column1' but not in contiguous form. For each occurrence of this type, i want to put value 'some data' in another column of same row.
  This is what it should be like.</p>
  
  <pre><code>Column1                        Column2
  This function takes input.     
  Other value                    don't care
  String as input                old_data
  
  Column1                        Column2
  
  This function takes input.     new_data
  Other value                    don't care
  String as input                old_data, new_data
  </code></pre>
  
  <p>If the column is empty it should simply add the data but if it already contains some old_data, it should append new_data delimited by comma.
  Is there any way to automate this task using powershell or otherwise.</p>
  
  <p><strong>EDIT</strong>
  With your help I have modified the code and it looks something like this.
  If value of column3 contains 'input' I have checked in Column 5 if there is already any data(either word character or ',') or not. But there is some problem in if statement.</p>
  
  <pre><code>$path = "d:\Book.csv"
  $data = Import-Csv $path
  
  $check = "ACCESS"
  $new_value = "access"
  
  $data | ForEach-Object {
      if($_.Column3 -match 'ACCESS'){
      if($_.Column5.Trim() -eq "") {
          $_.Column5 = $newvalue
      } elseif ($_.Column5 -match [\w,]) {
          $_.Column5 += "; $newvalue"
      }
  }
  }
  
  $data | Export-Csv d:\Book11.csv -NoTypeInformation
  </code></pre>