title: Importing CSV adding a column using PowerShell in C#
body: <p>I have a fairly large CSV file (27MB) with at least 400,000 rows in it. I want to add a column to it, just like in <a href="https://stackoverflow.com/q/17022017/4724142">this method</a> and export it, except that I have to do it in C#. I have added the <code>System.Management.Automation</code> and the <code>Microsoft.PowerShell</code> namespaces. I would also like the new column to be the first column in the CSV. How might I be able to achieve this in the fastest way possible?</p>
  
  <p>While the method used <a href="https://stackoverflow.com/questions/2081418/parsing-csv-files-in-c-sharp">here</a> could work, I specifically do not want to use any custom libraries not provided by windows.</p>
  
  <p>This is what I've tried, but it doesn't seem to work:</p>
  
  <pre><code>PowerShell ps = PowerShell.Create();
  ps.AddCommand("Import-Csv " + csvFileName + " |Select-Object *,@{Name='Name' ;Expression = {'setvalue'}} | Export-Csv " + csvFileName + " -NoTypeInformation");
  ps.Invoke();
  </code></pre>