title: Appending data to existing columns in csv file
body: <p>I am taking data from a table (Postgres) and trying to append to an existing file. The requirement is to insert data to respective columns</p>
  
  <p>I know only to append row-wise, not to specific columns</p>
  
  <pre><code>import psycopg2
  import csv
  
  conn_str="host='localhost' port='' "
  
  query=''
  
  cur.execute(query)
  
  title=[i[0] for i in cur.description]
  
  result=cur.fetchall()
  
  with open (file,'a') as csvfile:
      if result:
          c=csvwriter(csvfile)
          c.writerow(title)
          c.writerows(result)
  </code></pre>
  
  <p>Existing Csv file : </p>
  
  <pre><code>a,b,c,d,e (columns)
  1,2,3
  4,5,6
  </code></pre>
  
  <p>No data in d and e columns</p>
  
  <p>Required</p>
  
  <pre><code>a,b,c,d,e 
  1,2,3,x,y
  4,5,6,p,q
  </code></pre>
  
  <p>Post script execution only d and e columns should be filled. The table also has data pertinent to those fields.</p>