views:

57

answers:

3

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

+3  A: 

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

Domenic
Seems it's as easy as I thought, thanks a ton man!
Mercfh
IMO, those new to CSV files would be wise to keep the following quote from that article in mind: "No general standard specification for CSV exists. Variations between CSV implementations in different programs are quite common and can lead to interoperation difficulties."
Steve Fallows
It'll be done in MS Excel 2008 I believe
Mercfh
+1  A: 

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

Jerry Coffin
Any normal string is just separated by a comma though correct?
Mercfh
+2  A: 

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 : http://tools.ietf.org/html/rfc4180

kkress