我的 Excel CSV 文件中有数据。这是格式。
"","","","","the useful data
"
"","","","","the useful data
"
"","","","","the useful data
"
"","","","","the useful data
and the rest
"
如何格式化此文本,使最后一列末尾有“并使其像这样。
"","","","","the useful data"
"","","","","the useful data"
"","","","","the useful data"
"","","","","the useful data and the rest"
我为此使用 JavaScript。
最佳答案
var myCSVContent = ... // your csv here
myCSVContent
// removes line breaks within value and add whitespace
.replace(/((?:\\")|[^"])\n([^"])/g, "$1 $2")
// removes unwanted line breaks
.replace(/\n(["\w])([^"]|$)/g, "$1$2")
关于javascript 对 CSV 中的文本进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35410591/