title: How to strip multiple spaces, newline and tabs and just put single space in a text file?
body: <p>I have shakespeare's full works data from <a href="https://www.google.co.in/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwiltOu_wa7WAhUKN48KHVyWDIAQFggzMAE&amp;url=https%3A%2F%2Focw.mit.edu%2Fans7870%2F6%2F6.006%2Fs08%2Flecturenotes%2Ffiles%2Ft8.shakespeare.txt&amp;usg=AFQjCNEfRTHs2tqc-_fknloRt_HT-wC1ag" rel="nofollow noreferrer">here</a> that I want to use in a word embedding algorithm to create a model. The model's requirement is that the whole text be provided with only single spaces present and no other kind of whitespaces be present. How can I perform this? I found how to do this for a single string but it isn't working for a text file.</p>
  
  <p>My try(I am not very knowledgeable of python):</p>
  
  <pre><code>with open(file_path, 'r') as data:
      for line in data:
          cleanedline = line.strip('\n')
  </code></pre>
  
  <p>The cleanedline doesnt have the <code>\n</code> removed when printed, so I didn't write them back into file.</p>