title: Using Python for adding column in a CSV file
body: <p>I have csv file (inputFile) like below:</p>
  
  <pre><code>Temperature,2,3
  Temperature,5,6
  Pressure,11,14,45
  Pressure,13,23,16
  Humidity,21,24,25
  Humidity,27,28,26
  </code></pre>
  
  <p>and I want to write it into another file(outputFile), but in the following format:</p>
  
  <pre><code>Temperature,2,3,Pressure,11,14,45,Humidity,21,24,25
  Temperature,5,6,Pressure,13,23,16,Humidity,27,28,26
  </code></pre>
  
  <p>I have tried following Python code: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>with open('inputFile.csv','r') as csvinput:
   with open('outputFile.csv','w') as csvoutput:
    writer = csv.writer(csvoutput, delimiter= ',')
    writer = csv.writer(csvoutput)
    for row in csv.reader(csvinput):
     if (row[0] == "Pressure" or row[0] == "Humidity"):
      type =row[0]
      Value = row[1])
           writer.writerow(row + [np.asarray(type)] + [np.asarray(Value)])</code></pre>
  </div>
  </div>
  </p>
  
  <p>Which is giving the output in the follwoing format:</p>
  
  <pre><code>Temperature,2,3,Humidity,27
  
  Temperature,5,6,Humidity,27
  
  Temperature,8,9,Humidity,27
  
  Pressure,11,14,45,Pressure,11
  
  Pressure,13,23,16,Pressure,13
  
  Humidity,21,24,25,Humidity,21
  
  Humidity,27,28,26,Humidity,27
  </code></pre>
  
  <p>Please help!</p>