title: Need help on PowerShell column looping
body: <p>I have one requirement which should be done in windows PowerShell or command line. I need to split CSV file columns into <code>.txt</code> files.</p>
  
  <p><code>customer.csv</code>:</p>
  
  <pre><code>id,name
  1,a
  2,b
  </code></pre>
  
  <p>I need to split columns into text files (here rows and columns count are dynamic)</p>
  
  <p>The output text files should be as follows:</p>
  
  <p><code>id.txt</code>:</p>
  
  <pre><code>1
  2
  </code></pre>
  
  <p><code>name.txt</code>:</p>
  
  <pre><code>a
  b
  </code></pre>
  
  <p>I found the following script with the help of Google:</p>
  
  <pre><code>$a = Import-Csv "D:\Final\customer.csv"
  $b =  $a[0] | Get-Member | select -Skip 1 |  ? { $_.membertype -eq 'noteproperty'} 
  $b | % { $a | ft -Property $_.name | out-file "$($_.name).txt"  }
  </code></pre>
  
  <p>But the output text files are coming with column names, spaces &amp; etc.. I am unable to customize the above code. Kindly provide any help and let me know if any one needs more information.</p>
  
  <p>Thank you,</p>
  
  <p>Satish Kumar</p>