Focal Point
[CLOSED] CSV suppressing leading zeros on varchar

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9487077586

March 08, 2017, 01:28 PM
Suzy
[CLOSED] CSV suppressing leading zeros on varchar
I have a column defined in the database as VARCHAR2(6). The column contains some values with only numbers ie 000123 and others with letters as well ie. 12345A. In HTML and XLS these print as expected. In CSV, 000123 is seen as a number and the leading 0's are being deleted and aligned right, while the values with a letter at the end are aligned left. This causes an issue when a customer wants to upload the CSV file with 123 instead of 000123 in the column. I've tried to define the column as A6, and it still deletes the leading zeros in the affected rows. I've found a work-around by formatting the column to 000000 after it has opened. Or concatenating double quotes around the column. Any suggestions that would be invisible to the user?

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8.0.08
Solaris
HTML, PDF, XLS, CSV
March 08, 2017, 02:19 PM
Francis Mariani
If you open the file in Excel the leading zeros will indeed be suppressed, but if you open the file in a text editor, you will see the leading zeros.

DEFINE FILE CAR
TEST_COL/A6 = IF COUNTRY EQ 'JAPAN' THEN '000123' ELSE '12345A';
END

TABLE FILE CAR
PRINT
COUNTRY
TEST_COL
ON TABLE HOLD AS BASEAPP/HTEST1 FORMAT COMT
END


If it's Excel you're worried about, you could force it to leave the leading zeros by prefixing the value with an apostrophe, unfortunately it will be visible until you click and press enter in the cell.

SET HOLDLIST=PRINTONLY

DEFINE FILE CAR
TEST_COL/A6 = IF COUNTRY EQ 'JAPAN' THEN '000123' ELSE '12345A';
END

TABLE FILE CAR
PRINT
COUNTRY
COMPUTE TEST_COL_LEAD/A7 = '''' || TEST_COL;
ON TABLE HOLD AS BASEAPP/HTEST2 FORMAT COMT
END



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server