I’m facing an issue when exporting a DataFrame to a CSV file using df.to_csv() in pandas. The content in one of my DataFrame columns is multiline text, but when I export it to a CSV file, the entire text block gets written into a single cell without proper line breaks, resulting in an unreadable format.
For example, this is the kind of content I’m dealing with:
But after exporting with the following code:
df.to_csv('Findcomposer_updated.csv', index=False, quoting=pd.io.common.csv_quoting.QUOTE_ALL, encoding='utf-8', sep=',', line_terminator='n')
It shows
I want the CSV to properly reflect the multiline structure as it appears in the DataFrame, with line breaks, so that each section of the text appears on a new line within the same cell.
Thanks in advance for your help!