title: Python Special Characters Encoding
body: <p>I have a python script that reads a <strong>CSV</strong> file and writes in a <strong>XML</strong> file. I have been hitting a wall trying to find out how to read special characters such as: ç, á, é, í, etc. The script runs perfectly fine without special characters. That is the script header:</p>
  
  <pre><code># coding=utf-8
  
  '''
  @modified by: Julierme Pinheiro
  '''
  import os
  import sys
  import unittest
  from unittest import skip
  import csv
  import uuid
  import xml
  import xml.dom.minidom as minidom
  import owslib
  from owslib.iso import *
  import pyproj
  from decimal import *
  import logging
  </code></pre>
  
  <p>The way I retrieve information from the csv file is shown bellow:</p>
  
  <pre><code># add the title
                  title = data[1]
                  titleElement = identificationInfo[0].getElementsByTagName('gmd:title')[0]
                  titleNode = record.createTextNode(title)
                  titleElement.childNodes[1].appendChild(titleNode)
                  print "Title:" + title
  </code></pre>
  
  <p>Note: If data[1], second column in the csv file, contains a special character as found in "Navega<strong>çã</strong>o" the script fails (<strong>It does not write anything in the xml file</strong>).</p>
  
  <p>The way a new XML file is created based on a blank Template XML is shown bellow:</p>
  
  <pre><code> # write out the gemini record
                  filename = '../output/%s.xml' % fileId
                  with open(filename,'w') as test_xml:
                      test_xml.write(record.toprettyxml(newl="", encoding="utf-8"))
              except:
                  e = sys.exc_info()[1]
                  logging.debug("Import failed for entry %s" % data[0])
                  logging.debug("Specific error: %s" % e)
  
      @skip('')
      def testOWSMetadataImport(self):
          raw_data = []
          with open('../input/metadata_cartapapel.csv') as csvfile:
              reader = csv.reader(csvfile, dialect='excel')
              for columns in reader:
                  raw_data.append(columns)   
  
          md = MD_Metadata(etree.parse('gemini-template.xml'))
          md.identification.topiccategory = ['farming','environment']
          print md.identification.topiccategory
          outfile = open('mdtest.xml','w')
          # crap, can't update the model and write back out - this is badly needed!!
          outfile.write(md.xml) 
  
  
  if __name__ == "__main__":
      unittest.main()
  </code></pre>
  
  <p>Could someone help to solve this issue, please?</p>
  
  <p>Thank you in advance for your time.</p>