title: Convert CSV to YAML, with Unicode?
body: <p>I'm trying to convert a CSV file, containing Unicode strings, to a YAML file using Python 3.4.</p>
  
  <p>Currently, the YAML parser escapes my Unicode text into an ASCII string.  I want the YAML parser to export the Unicode string <em>as</em> a Unicode string, without the escape characters.  I'm misunderstanding something here, of course, and I'd appreciate any assistance.</p>
  
  <p><em>Bonus points</em>: how might this be done with Python 2.7?</p>
  
  <p><strong>CSV input</strong></p>
  
  <pre><code>id, title_english, title_russian
  1, A Title in English, Название на русском
  2, Another Title, Другой Название
  </code></pre>
  
  <p><strong>current YAML output</strong></p>
  
  <pre><code>- id: 1
    title_english: A Title in English
    title_russian: "\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u043D\u0430\
      \ \u0440\u0443\u0441\u0441\u043A\u043E\u043C"
  - id: 2
    title_english: Another Title
    title_russian: "\u0414\u0440\u0443\u0433\u043E\u0439 \u041D\u0430\u0437\u0432\u0430\
        \u043D\u0438\u0435"
  </code></pre>
  
  <p><strong>desired YAML output</strong></p>
  
  <pre><code>- id: 1
    title_english: A Title in English
    title_russian: Название на русском
  - id: 2
    title_english: Another Title
    title_russian: Другой Название
  </code></pre>
  
  <p><strong>Python conversion code</strong></p>
  
  <pre><code>import csv
  import yaml
  in_file  = open('csv_file.csv', "r")
  out_file = open('yaml_file.yaml', "w")
  items = []
  
  def convert_to_yaml(line, counter):
      item = {
          'id': counter,
          'title_english': line[0],
          'title_russian': line[1]
      }
      items.append(item)
  
  try:
      reader = csv.reader(in_file)
      next(reader) # skip headers
      for counter, line in enumerate(reader):
          convert_to_yaml(line, counter)
      out_file.write( yaml.dump(items, default_flow_style=False) )
  
  finally:
      in_file.close()
      out_file.close()
  </code></pre>
  
  <p>Thanks!</p>