CSV columns getting converted to Date Format.

Sundreamz

New Member
Hello,

We have a problem of character fields output to a CSV file being coverted into date format.
E.g.
A file comes in with 02-3724 in the file description 1 field. However in the report, the file description would show as Feb-24, instead of 02-3724.

Any information regarding how to change the code so that the CSV file understands that the data is of string fromat and needs to be displayed accordingly.

Please provide any useful info.
Thanks in Advance.

Rgds,
Sundreamz
 
Hi,

I think the problem is not so much making the csv file understand that some value is a character, date or something else. A csv file is nothing more than an ascii file that contains comma separated values. If you would open the file in for instance Notepad you would see that the value you export is indeed 02-3724. The real issue I believe you have is that the program you use that reads the file (probably Excel) interprets these values based on their content (and the dash and the numbers makes it think it is looking at a date and tries to be clever about it).

If you are using Excel, you should be able to use the Cell Formatting options in order to display the values correctly after you have opened the csv file. If this is not suitable you may need to see whether it is feasable to export your data in another file format. Excel can for instance read xml files, in which you can specify all sorts of formatting options. And since Progress can create xml files on both Windows and Unix platforms that may be a better option for you.

Good luck,

Paul
 
Thanks for your prompt reply paul.
I got your point. I was jus wondering if I could make the excel understand that the description is a character, not a date. Appending the ouput field with a Specal charater is an option I have.
eg. output 02-3724 as '02-3724 .
Is there a better option on these lines. so that I can handle it in the code.

Rgds,
Sandeep
 
You could surround the field with double quotes and add a space in front. This way it will be recognised as a character field and the space is easily trimmed off for further processing if nessecary.

e.g.
Code:
put stream Sout unformatted '" ' field '"'.

HTH,
Casper
 
Back
Top