title: Output CSV is in binary with python 3.10
body: <p>I am trying to create a CSV file from a OSM file.  However, every time I run my code I'm getting a &quot;B&quot; in the output, like this,</p>
  <p>b'id',b'lat',b'lon',b'user',b'uid',b'version',b'changeset',b'timestamp'</p>
  <p>I can NOT figure out what I'm doing wrong.</p>
  <p>Code is below.</p>
  <pre><code>def get_element(osm_file, tags=('node', 'way', 'relation')):
      &quot;&quot;&quot;Yield element if it is the right type of tag&quot;&quot;&quot;
  
      context = ET.iterparse(osm_file, events=('start', 'end'))
      _, root = next(context)
      for event, elem in context:
          if event == 'end' and elem.tag in tags:
              yield elem
              root.clear()
  
  
  def validate_element(element, validator, schema=SCHEMA):
      &quot;&quot;&quot;Raise ValidationError if element does not match schema&quot;&quot;&quot;
      if validator.validate(element, schema) is not True:
          field, errors = next(validator.errors.iteritems())
          message_string = &quot;\nElement of type '{0}' has the following errors:\n{1}&quot;
          error_string = pprint.pformat(errors)
  
          raise Exception(message_string.format(field, error_string))
  
  
  class UnicodeDictWriter(csv.DictWriter, object):
      &quot;&quot;&quot;Extend csv.DictWriter to handle Unicode input&quot;&quot;&quot;
  
      def writerow(self, row):
          super(UnicodeDictWriter, self).writerow({
              k: (v.encode('utf-8') if isinstance(v, str) else v) for k, v in row.items()
          })
  
      def writerows(self, rows):
          for row in rows:
              self.writerow(row)
  
  
  # ================================================== #
  #               Main Function                        #
  # ================================================== #
  def process_map(file_in, validate):
      &quot;&quot;&quot;Iteratively process each XML element and write to csv(s)&quot;&quot;&quot;
  
      with codecs.open(NODES_PATH, 'w') as nodes_file, \
              codecs.open(NODE_TAGS_PATH, 'w') as nodes_tags_file, \
              codecs.open(WAYS_PATH, 'w') as ways_file, \
              codecs.open(WAY_NODES_PATH, 'w') as way_nodes_file, \
              codecs.open(WAY_TAGS_PATH, 'w') as way_tags_file:
  
          nodes_writer = UnicodeDictWriter(nodes_file, NODE_FIELDS)
          node_tags_writer = UnicodeDictWriter(nodes_tags_file, NODE_TAGS_FIELDS)
          ways_writer = UnicodeDictWriter(ways_file, WAY_FIELDS)
          way_nodes_writer = UnicodeDictWriter(way_nodes_file, WAY_NODES_FIELDS)
          way_tags_writer = UnicodeDictWriter(way_tags_file, WAY_TAGS_FIELDS)
  
          nodes_writer.writeheader()
          node_tags_writer.writeheader()
          ways_writer.writeheader()
          way_nodes_writer.writeheader()
          way_tags_writer.writeheader()
  
          validator = cerberus.Validator()
  
          for element in get_element(file_in, tags=('node', 'way')):
              el = shape_element(element)
              if el:
                  if validate is True:
                      validate_element(el, validator)
  
                  if element.tag == 'node':
                      nodes_writer.writerow(el['node'])
                      node_tags_writer.writerows(el['node_tags'])
                  elif element.tag == 'way':
                      ways_writer.writerow(el['way'])
                      way_nodes_writer.writerows(el['way_nodes'])
                      way_tags_writer.writerows(el['way_tags'])
  </code></pre>