如何写入.CSV文件 [英] how to write to .CSV file

查看:119
本文介绍了如何写入.CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况是我的代码返回一个浮点数组作为querry到instrument的结果。现在我想将这些结果写入.csv文件,该文件还有一个针对返回的每个数据的标头。什么是在C#中最好的方法。

I have a situation where my code returns a float array as results from a querry to instrument. Now I want to write these results in to .csv file, which also has a header against each data returned. Whats the best way to do that in C#.

推荐答案

最好的方法是手动完成。没有内置的神奇方法来做到这一点。 CSV非常简单。只需将数据存储在String变量或StringBuilder中,然后使用 File.WriteAllText [ ^ ]保存到文件。很容易做到。
The best way is to do it manually. There is no built-in magic way to do it. CSV is very simple. Just store your data in a String variable or a StringBuilder and then use File.WriteAllText[^] to save to a file. Very easy to do.


这篇关于如何写入.CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆