title: Python 2.7 CSV file read/write \xef\xbb\xbf code
body: <p>I have a question about Python 2.7 read/write csv file with '<code>utf-8-sig</code>' code, my csv . header is</p>
  
  <pre><code>['\xef\xbb\xbfID;timestamp;CustomerID;Email']
  </code></pre>
  
  <p>there have some code(<code>"\xef\xbb\xbfID"</code>) I read from file <code>A.csv</code> and I want write the same code and header to file <code>B.csv</code></p>
  
  <p>My print log is shows:</p>
  
  <pre><code>['\xef\xbb\xbfID;timestamp;CustomerID;Email']
  </code></pre>
  
  <p>But the actual output file header it looks like </p>
  
  <pre><code>ÔªøID;timestamp
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tHrId.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tHrId.png" alt="enter image description here"></a></p>
  
  <p>Here is the code:</p>
  
  <pre><code>def remove_gdpr_info_from_csv(file_path, file_name, temp_folder, original_header):
      new_temp_folder = tempfile.mkdtemp()
      new_temp_file = new_temp_folder + "/" + file_name
      # Blanked new file
      with open(new_temp_file, 'wb') as outfile:
          writer = csv.writer(outfile, delimiter=";")
          print original_header
          writer.writerow(original_header)
          # File from SFTP
          with open(file_path, 'r') as infile:
              reader = csv.reader(infile, delimiter=";")
              first_row = next(reader)
              email = first_row.index('Email')
              contract_detractor1 = first_row.index('Contact Detractor (Q21)')
              contract_detractor2 = first_row.index('Contact Detractor (Q20)')
              contract_detractor3 = first_row.index('Contact Detractor (Q43)')
              contract_detractor4 = first_row.index('Contact Detractor(Q26)')
              contract_detractor5 = first_row.index('Contact Detractor(Q27)')
              contract_detractor6 = first_row.index('Contact Detractor(Q44)')
              indexes = []
              for column_name in header_list:
                  ind = first_row.index(column_name)
                  indexes.append(ind)
  
              for row in reader:
                  output_row = []
                  for ind in indexes:
                      data = row[ind]
                      if ind == email:
                          data = ''
                      elif ind == contract_detractor1:
                          data = ''
                      elif ind == contract_detractor2:
                          data = ''
                      elif ind == contract_detractor3:
                          data = ''
                      elif ind == contract_detractor4:
                          data = ''
                      elif ind == contract_detractor5:
                          data = ''
                      elif ind == contract_detractor6:
                          data = ''
                      output_row.append(data)
                  writer.writerow(output_row)
      s3core.upload_files(SPARKY_S3, DESTINATION_PATH, new_temp_file)
      shutil.rmtree(temp_folder)
      shutil.rmtree(new_temp_folder)
  </code></pre>