使用CsvHelper强制LF行结尾 [英] Enforce LF line endings with CsvHelper
问题描述
如果我有一些LF
转换(使用N ++)的CSV文件,则每次我使用JoshClose的CsvHelper
将数据写入它们时,行尾都回到CRLF.
If I have some LF
converted (using N++) CSV files, everytime I write data to them using JoshClose's CsvHelper
the line endings are back to CRLF.
由于SQL Server中的CLRF ROWTERMINATORS
出现问题,我希望保留行尾,例如文件的初始状态.
Since I'm having problems with CLRF ROWTERMINATORS
in SQL Server, I whish to keep my line endings like the initital status of the file.
在区域性设置中找不到它,我编译了自己的库版本.
Couldn't find it in the culture settings, I compile my own version of the library.
如何进行?
推荐答案
据我所知,行终止符不受CvsHelper的控制.我已经通过调整传递给CsvWriter的文件编写器来使其工作.
From what I can tell, the line terminator isn't controlled by CvsHelper. I've gotten it to work by adjusting the File writer I pass to CsvWriter.
TextWriter tw = File.CreateText(filepathname);
tw.NewLine = "\n";
CsvWriter csvw = new CsvWriter(tw);
csvw.WriteRecords(records);
csvw.Dispose();
这篇关于使用CsvHelper强制LF行结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!