excel – C++ Outputting to .CSV Files – Education Career Blog

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


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


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


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).

Leave a Comment