Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I convert LF to CRLF?
    primarykey
    data
    text
    <p>I found a list of the majority of English words online, but the line breaks are of unix-style (encoded in Unicode: UTF-8). I found it on this website: <a href="http://dreamsteep.com/projects/the-english-open-word-list.html" rel="noreferrer">http://dreamsteep.com/projects/the-english-open-word-list.html</a></p> <p>How do I convert the line breaks to CRLF so I can iterate over them? The program I will be using them in goes through each line in the file, so the words have to be one per line.</p> <p>This is a portion of the file: <code>bitbackbitebackbiterbackbitersbackbitesbackbitingbackbittenbackboard</code></p> <p>It should be:</p> <pre><code>bit backbite backbiter backbiters backbites backbiting backbitten backboard </code></pre> <p>How can I convert my files to this type? Note: it's 26 files (one per letter) with 80,000 words or so in total (so the program should be very fast).</p> <p>I don't know where to start because I've never worked with unicode. Thanks in advance!</p> <p>Using <code>rU</code> as the parameter (as suggested), with this in my code:</p> <pre><code>with open(my_file_name, 'rU') as my_file: for line in my_file: new_words.append(str(line)) my_file.close() </code></pre> <p>I get this error:</p> <pre><code>Traceback (most recent call last): File "&lt;pyshell#5&gt;", line 1, in &lt;module&gt; addWords('B Words') File "D:\my_stuff\Google Drive\documents\SCHOOL\Programming\Python\Programming Class\hangman.py", line 138, in addWords for line in my_file: File "C:\Python3.3\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 7488: character maps to &lt;undefined&gt; </code></pre> <p>Can anyone help me with this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload