Reputation: 3362
I have this:
with open(str(ssis_txt_file_names_only[a]) + '.dts', 'w', encoding='utf16') as file:
whatever = whatever.replace("\n","")
print(whatever)
file.write(str(whatever))
When I do a print(whatever) all of the text appears on 1 line instead of broken up. Do anyone know what might be the cause?
Currently, my output looks like this:
>N</IsConnectionProperty> <Flags> 0</Flags> </AdapterProperty> <AdapterProperty>
What I want is this:
>N<I/IsConnectionProperty>
<Flags> 0</Flags>
</AdapterProperty>
<AdapterProperty>
Shouldn't the \n
be doing this?
Upvotes: 0
Views: 37
Reputation: 14849
Your line whatever = whatever.replace("\n","")
is replacing all linebreaks with nothing, so that's the culprit.
To your issue in the comments, Notepad doesn't recognize \n
only as a linebreak; it needs the full Windows-style \r\n
. Chances are if you open it in another editor, you'll see the linebreaks if you comment out the .replace
line. Alternatively, if you make the line read whatever = whatever.replace("\n","\r\n")
, it should display as expected in Notepad.
Upvotes: 1