How to keep the newline \r\n in the cell in the csv file

How to keep the newline \r\n in the cell in the csv file

1. Problem description

,We all know that the cells are divided by in the csv file .

But if there is a newline in the content of a cell:

34, KyleBing, 你好 # 这里换行了
我的名字是 kyebing
35, Tina, hello
36, Lucy, nice to meet you

When opened with Excel, the content is messed up:

insert image description here

Two, the solution

Just add double quotes around the cell content to wrap it""

The content of the above example is:

34, KyleBing, "你好
我的名字是 kyebing"  # 这样就不会在 Excel 中换行到下一条数据了
35, Tina, hello
36, Lucy, nice to meet you

When opening the csv file again, Excel can display it in the correct format.
insert image description here

Guess you like

Origin blog.csdn.net/KimBing/article/details/131608488