title: Issues Writing xpath objects with commas out to CSV in Python
body: <p>Building a web scraper for use internally on sites I manage and I am having issues outputting xpath lists that happen to include commas in the output string.  I know that I need to handle the commas inside the string lists differently than the commas that separate the values meant to be separated into columns</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import requests
  from lxml import html
  import urlparse
  import collections
  import csv
  import time
  
  # Settings
  statingurl = 'http://www.somdomain.com'
  domain = 'somedomain'
  
  # filename
  timestr = time.strftime("%m-%d-%Y-%H-%M-%S")
  f = open('scrape-output\\'+domain+'-metadata-'+timestr+'.csv', 'a+')
  
  # Create URL Queue, Set Start, Crawl
  urls_queue = collections.deque()
  urls_queue.append(statingurl)
  found_urls = set()
  found_urls.add(statingurl)
  
  # Set Column Headers for the file
  colheader = "URL Crawled, Title Tag, Meta Description, H1, H2, H3, H4, H5, H6, Image Source, Image Alt"
  f.write(colheader)
  f.write("\n")
  
  while len(urls_queue):
      url = urls_queue.popleft()
      page_url = url
      print "\n"
      print "************************************************************"
      print "\n"
  
      # Use Requests to get Metadata
      if url.startswith(statingurl):
          print "Connecting to %s" % (url,)
          page = requests.get(url)
          tree = html.fromstring(page.content)
          print "\n"
  
      # Extract Metadata elements from the html tree
      title = tree.xpath('//title/text()')
      description = tree.xpath("//head/meta[@name='description']/@content")
      h1 = tree.xpath('//h1/text()')
      h2 = tree.xpath('//h2/text()')
      h3 = tree.xpath('//h3/text()')
      h4 = tree.xpath('//h4/text()')
      h5 = tree.xpath('//h5/text()')
      h6 = tree.xpath('//h6/text()')
      imgsrc = tree.xpath('//img/@src')
      imgalt = tree.xpath('//img/@alt')
  
      # Output Metadata
      print 'Found %s Title' % len(title) 
      print title,"\n"
      print 'Found %s Description' % len(description)
      print description,"\n"  
      print 'Found %s H1' % len(h1)   
      print h1
      print 'Found %s H2' % len(h2)   
      print h2
      print 'Found %s H3' % len(h3)   
      print h3
      print 'Found %s H4' % len(h4)   
      print h4
      print 'Found %s H5' % len(h5)   
      print h5
      print 'Found %s H6' % len(h6)   
      print h6    
      print '\n'
      print 'Found %s Image Paths' % len(imgsrc)
      print 'Images Src:'
      print imgsrc 
      print "\n"
      print 'Found %s Image Alt Tags' % len(imgsrc)   
      print 'Image Alt:'
      print imgalt
      print "\n"
  
      # Finds links on page; Add URL to Queue
      print "Looking for links"
      links = {urlparse.urljoin(page.url, url) for url in tree.xpath('//a/@href') if urlparse.urljoin(page.url, url).startswith('http')}
  
      print "Set difference to find new URLs"
      # Set difference to find new URLs
      for link in (links - found_urls):
          found_urls.add(link)
          urls_queue.append(link) 
      print '\n %s URLs in Queue' % len(urls_queue)
  
      # Write Output to file and repeat loop
      output = "%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s" % (page_url.encode('utf-8'), title, description, h1, h2, h3, h4, h5, h6, imgsrc, imgalt)
      f.write(output)
      f.write('\n')
  </code></pre>
  
  <p>If someone could just help me understand say for the description value how to ensure that the  comma in the description object is parsed as a string complete with the comma in it, into the csv file, I would greatly appreciate it.  There is more work to do on this script past that, but that is my immediate issue.</p>
  
  <p>Thanks.</p>