C++输出到 .CSV 文件

发布于 2024-09-28 12:18:05 字数 472 浏览 1 评论 0原文

所以基本上我以前从未使用过 CSV 文件,但我正在制作一个程序,该程序将计算大量数据并将其输出到文件(8 个单独的文件)

基本上它将执行一个公式。然后将其输出为:(| 表示单独的列)

int | int | int | float | string | int | int | int | float | final_float
int | int | int | float | string | int | int | int | float | final_float (different values)

我基本上比较两个函数......并为每个函数获取一个浮点数,然后在最后得到最终的浮点数。如果将其放入 Excel 文件中,那就太棒了!比手动输入要容易得多。

我听说做一个 .csv 文件,你只需简单地用逗号分隔“列”,用 endl 分隔行。

这就是全部了吗?或者是他们更多?

谢谢大家

So basically i've never worked with CSV files before, but im making a program thats going to be calculating and outputting ALOT of data to files (8 separate files)

Basically it's going to do a formula. then output it as something like: (| means seperate column)

int | int | int | float | string | int | int | int | float | final_float
int | int | int | float | string | int | int | int | float | final_float (different values)

Im basically comparing two functions....and getting a float for each, then getting a final float at the end. And getting this into an excel file would be grrrreat! and alot easier then manually inputting them.

I've heard to do a .csv file you simply seperate the "columns" but comma's, and the rows by endl's.

Is that all there is too it? or is their more?

Thanks all

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

从﹋此江山别 2024-10-05 12:18:05

尽管可能存在一些轻微的技术细节,但在大多数情况下确实就是这样

Although there can be some slight technicalities, in most cases indeed that is all there is to it.

£烟消云散 2024-10-05 12:18:05

关于如何处理带有嵌入逗号和引号边界的字符串有一些额外的规则,但只要您只使用数值,就应该没问题。如果您想要详细信息,可以在这里找到 RFC:https://www.rfc-editor .org/rfc/rfc4180

There are a couple of extra rules on how you handle strings with embedded commas and quotation boundaries, but as long as you're just using numeric values you should be fine. The RFC can be found here if you want the gory details : https://www.rfc-editor.org/rfc/rfc4180

剪不断理还乱 2024-10-05 12:18:05

如果您创建的只是未格式化的数字,是的,这就是它的全部内容。如果您可能需要处理包含逗号在内的格式化数字,则可以将其括在引号中,以防止逗号将其解释为两个单独的数字。如果您想包含文本,还值得了解的是,您可以通过加倍引号在字段中包含引号(例如,“这是一个带有嵌入式引号的“字段””将显示为带有引号的字段)围绕字段)。

If all you're creating is unformatted numbers, yes, that's about all there is to it. If you might have to deal with numbers that have been formatted including commas, you can enclose it in quotes to keep the comma from getting it interpreted as two separate numbers. If you want to include text, it's also worth knowing that you can include a quote mark in a field by doubling the quote mark (e.g., "this is a ""field"" with embedded quotes" would come out as one field with quotes around field).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文