title: How to properly remove carriage return in python while using with dictwriter (newline='' does not help)
body: <p>I have a simple pythono code that parses json file and returns it as dictionary. I have to write this in to CSV file but only with the LF as a line terminator. However, Carriage return appears anyway even using newline=''. wb mode is not an option as i receive this error </p>
  
  <p><strong>return self.writer.writerow(self._dict_to_list(rowdict))
  TypeError: a bytes-like object is required, not 'str'</strong></p>
  
  <p>My code for CSV writing:</p>
  
  <pre><code>with open(statsFilePath,'w+', newline='', encoding='utf8') as f:
    writer = csv.DictWriter(f, header , delimiter = '|')
    for row in result:
      writer.writerow(row)
  </code></pre>
  
  <p>And here is the screenshot of what i see in Notepad++</p>
  
  <p><a href="https://i.stack.imgur.com/jhfJL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jhfJL.jpg" alt="crLf"></a></p>
  
  <p><strong>UPDATE, SOLVED</strong></p>
  
  <p>The DictWriter used the default line terminator. Changing the code to this, solved the issue:</p>
  
  <pre><code>with open(statsFilePath,'w+', newline='', encoding='utf8') as f:
      writer = csv.DictWriter(f, header , delimiter = '|', lineterminator="\n")
      for row in result:
          writer.writerow(row)  
  </code></pre>