简体   繁体   中英

How to wrap text with in a column while writing in csv file using python

I am trying to export a file as csv. I need to wrap text for a particular column while writing in csv file. I have a too long string. i need to write it in a csv file using python. While trying to write, it doesn't write in a single cell. some of the lines are written into next rows. I need to write the whole string in a single cell. Please help me to do this.

CSV is not formatted. If you want to format the text in the cells, you should consider writing a proper Excel or PDF file.

Anyway it looks like that newline characters (\\n or \\r\\n) can be used in CSV files if using semicolon as separator, so this may not be portable.

To write an Excel file, you can use libraries like openpyxl or xlwt .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM