title: Appending data to csv file
body: <p>I am trying to append 2 data sets to my csv file. Below is my code. The code runs but my data gets appended below a set of data in the first column (i.e. col[0]). I would however like to append my data sets in separate columns at the end of file. Could I please get advice on how I might be able to do this? Thanks.  </p>
  
  <pre><code>import csv
  
  Trial = open ('Trial_test.csv', 'rt', newline = '')
  reader = csv.reader(Trial)
  
  Trial_New = open ('Trial_test.csv', 'a', newline = '')
  writer = csv.writer(Trial_New, delimiter = ',')
  
  Cortex = []
  Liver = []
  
  for col in reader:
      Cortex_Diff = float(col[14])
      Liver_Diff = float(col[17])
      Cortex.append(Cortex_Diff)
      Liver.append(Liver_Diff)
  Avg_diff_Cortex = sum(Cortex)/len(Cortex)
  Data1 = str(Avg_diff_Cortex)
  Avg_diff_Liver = sum(Liver)/len(Liver)
  Data2 = str(Avg_diff_Liver)
  writer.writerows(Data1 + Data2)
  
  
  Trial.close()
  Trial_New.close()
  </code></pre>