I'm making these report files and am trying to append a blank line in between each cycle of my loop, just to help with readability.
Usually, I can just open the file and f.write('\n') to do this - for whatever reason now when I view this file it will not work. I have a few conditions so I've tried adding '\n' to the end of my output strings. Some examples below. Any ideas?? I've tried in write mode too and it doesn't work.
Fails
#enter MSI status into output csv
with open(f'{date}-output.csv', 'a') as f:
#workaround f strings with \n
newline= '\n'
f.write(f'MSI status for {sample_id},{msi_result}{newline}')
Fails
#enter MSI status into output csv
with open(f'{date}-output.csv', 'a') as f:
f.write(f'MSI status for {sample_id},{msi_result}\n')
Fails
#enter MSI status into output csv
with open(f'{date}-output.csv', 'a') as f:
f.write(f'MSI status for {sample_id},{msi_result}')
f.write('\n')
I've even got one that fails on my except, where I'm just doing
#insert new line on either success or failure
with open(f'{date}-output.csv', 'a') as f:
f.write('\n')
try this:
it should work