title: split csv column entry on space using python
body: <p>I am trying to create a new csv file using python. The new csv file will be the same, but have one entry split based on a space delimiter.</p>
  
  <p>My method is to open the files with read and write access respectively, skip over the headers, then write out the specific column headings I want in the csv.</p>
  
  <p>Then iterate over each rows amending the appropriate section and writing the row to the new file using the <code>.writerow</code> function.</p>
  
  <p>One iteration over the row creates 
  <code>['data1', 'data2', 'data3 data4', 'data5', 'data6', 'data7' etc. ]</code></p>
  
  <p>So in this case I'm selecting <code>row[2]</code> to select the <code>'data3 data4'</code> part and trying to split these to create a list that looks like <code>['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7' etc. ]</code></p>
  
  <p>I have tried using <code>.split</code> which gives me a list within a list, I've tried <code>.slicing</code> which means I can show either <code>data3</code> or <code>data4</code>. I've also tried the <code>.replace</code> which gives me <code>['data1', 'data2', 'data3,data4', etc.]</code>. I'm quite frustrated and wondering if anyone might give me the a hint as to the probably quite simple solution that i'm missing. Full code is below. </p>
  
  <pre><code>import csv
  
  with open('filepath', mode="rU") as infile:
      with open('filepath', mode="w") as outfile:
  
          csv_f = csv.reader(infile)
          next(csv_f, None)  # skip the headers
  
          writer = csv.writer(outfile)
          writer.writerow(['dataheader1', 'dataheader2', 'dataheader3', 'dataheader4', 'dataheader5', 'dataheader6', 'dataheader7' etc. ])
  
      for row in csv_f:
          row[2] = row[2].replace(' ', ',')
          print row
  </code></pre>