存储值并输出 csv 文件
我是 C# 和 WPF 新手。我需要编写一个程序来收集和显示 RS232 数据并将其保存为 CSV 文件。我需要数据库还是 XML?有没有人可以推荐相关的教程?
I'm new to C# and WPF. I will need to write a program to collect and display RS232 data and save it as a CSV file. Do I need database or XML? Is there any relevant tutorial anyone could recommend?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
存储周围..
您想对数据进行排序/过滤/搜索吗?
然后我将其存储在 SQL 数据库中,稍后将其导出到 CSV(使用简单的 StringWriter)。
如果您不想访问数据,只需收集数据并将其放入 CSV 中,我会在数据进入时将其写入 CSV。
对于读取 CSV,我建议使用 LINQ to CSV执行。
例如 http://www.codeproject.com/KB/linq/LINQtoCSV.aspx
或 http://www.thinqlinq.com/Post。 aspx/标题/LINQ-to-CSV-using-DynamicObject
Around the storage..
Do you want to sort / filter / search the data?
Then I would store it in a SQL Database and export it later on to CSV (using a simple StringWriter).
If you don't want to access the data, just collect it and put it into CSV I would simply write it to CSV as the data comes in.
For reading CSV I would recommend using a LINQ to CSV implementation.
E.g. http://www.codeproject.com/KB/linq/LINQtoCSV.aspx
or http://www.thinqlinq.com/Post.aspx/Title/LINQ-to-CSV-using-DynamicObject
对 RS232 不太了解,但我猜这是来自串行端口的二进制数据?
我对将其输出为 CSV 文件的整个想法提出质疑 - 基于文本的格式对此并不理想。
XML 是更好的选择 - 您可以使用 Base64 来解决编码问题,并且可以合理地构建文档以满足您的目的。
另一个想法,取决于您想要做什么,可能是使用基于文件的数据库。我也不是指 MS Access(吐槽!) - 查找 SQLite。
如果有人真的强迫您采用 CSV 路径来获取二进制数据,那么我建议您和他们需要讨论一下,归根结底,这是否真的是一个好主意。
Don't know much about RS232, but I gather this is binary data coming off a serial port?
I would question the whole idea of outputing it as a CSV file - text based formats are not ideal for this.
XML is a better choice - you could use Base64 to sort out the encoding issues, and you could structure your document sensibly to meet your purposes.
Another idea, depending on what you're trying to do, might be to use a file based Database. I don't mean MS Access either (Spit!) - look up SQLite.
If someone is really forcing you down a CSV route for binary data, then I suggest you and they need to have a talk about whether this really is, when it comes down to it, really such a great idea.