Problem with csv file gen from C++

Hi Frnds,

I have a problem with csv file gen.

Here is the description:

My code genereates a csv file as output in which a particular column("OUTPUT NUMBER")contains a string value fetched from db.

Now the problem is when i open this csv file the OUTPUT NUMBER column misses the zero("0") digit for example suppose the column has 3 values 01,02,12 then when the file is opened this column will show values as 1,2,12.

Does anyone has a soln for this

Thanks in advance

open how, with what, where?

Presumably that's because it is treating them as numbers, not text.

When i open the csv file with MS excel ya that assumes the field as number not as text but how do i solve this

does

cat file.csv

show the correct data? If so then that is what matters. MS excel is probably reformatting the data.

Make the data as follows....

"01","02","03","04"

Evan including "" doesnt works

Ya wen seen in unix server in csv file data its written correctly that is 01 02..
but wen i open this file using excel in my windows system data is getting formatted is there any way to solve this

I have successfully used the quoting strategy when preparing CSV files for Excel. What character are you using as your field separator?

I am using a comma(,)

Yes, I've just tried

" 01"," 02"," 03"," 04"
" 01"," 02"," 03"," 04"

and

"01","02","03","04"
"01","02","03","04"

and indeed it drops the leading zero.

I suppose that comes from Excel trying to make the best guess given that it's a spreadsheet.

Not a very nice one, requiring manual excel action:

Select column->right click->Format cells choose "special" and type in 0# as the format and numbers will be padded with a zero if single digits. 00# for padding to three digits etc.