Focal Point
[SOLVED] CSV With Headers & No Space Padding

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

October 09, 2014, 01:24 PM
ColdWhiteMilk
[SOLVED] CSV With Headers & No Space Padding
When I output to COMMA, the resulting csv file has the layout I'm looking for (comma separated, with double quotes around each field value.

However the field values appear to be space padded to the same length. Is there a way to remove this space padding?


My Code:

TABLE FILE CAR
PRINT 
COUNTRY  
MODEL
ON TABLE PCHOLD FORMAT COMMA
END

This message has been edited. Last edited by: ColdWhiteMilk,


Production - 7.6.4
Sandbox - 7.6.4
October 09, 2014, 02:01 PM
Francis Mariani
See if format COM fits your needs.

quote:
Saves the data values as a variable-length text file with fields separated by commas and with character values enclosed in double quotation marks. Leading blanks are removed from numeric fields, and trailing blanks are removed from character fields. To issue a request against this data source, the setting PCOMMA=ON is required.

This format also includes a built-in safety feature, which allows embedded quotes within character fields. A second double quote (") is inserted adjacent to the existing one. For example, if you input Joe "Smitty" Smith, the output is Joe ""Smitty"" Smith.



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
October 09, 2014, 02:19 PM
ColdWhiteMilk
Where did you find this quote?

Changing to the below gives me a CSV, but no quotes.

TABLE FILE CAR
PRINT 
COUNTRY  
MODEL
ON TABLE PCHOLD FORMAT COM
END




Production - 7.6.4
Sandbox - 7.6.4
October 09, 2014, 02:56 PM
Francis Mariani
-* File fm_csv1.fex
TABLE FILE CAR
PRINT 
COUNTRY  
MODEL
ON TABLE PCHOLD FORMAT COM
END


"ENGLAND","V12XKE AUTO"
"ENGLAND","XJ12L AUTO"
"ENGLAND","INTERCEPTOR III"
"ENGLAND","TR7"
"JAPAN","B210 2 DOOR AUTO"
"JAPAN","COROLLA 4 DOOR DIX AUTO"
"ITALY","2000 4 DOOR BERLINA"
"ITALY","2000 GT VELOCE"
"ITALY","2000 SPIDER VELOCE"
"ITALY","DORA 2 DOOR"
"W GERMANY","100 LS 2 DOOR AUTO"
"W GERMANY","2002 2 DOOR"
"W GERMANY","2002 2 DOOR AUTO"
"W GERMANY","3.0 SI 4 DOOR"
"W GERMANY","3.0 SI 4 DOOR AUTO"
"W GERMANY","530I 4 DOOR"
"W GERMANY","530I 4 DOOR AUTO"
"FRANCE","504 4 DOOR"


Documentation: Creating Reports With WebFOCUS Language > Saving and Reusing Your Report Output > Choosing Output File Formats > FORMAT COM

Note that when a csv file is opened in Excel, you won't see the double quotes. If the file is opened in a text editor, you should see the double quotes. I'm doing this in v7.7.05 but this behaviour should be the same for v7.6.


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
October 09, 2014, 05:01 PM
ColdWhiteMilk
ok, that's working.

I thought I was doing the same thing, but after run or run deferred, it was opening by default in Excel and then I was saving it as CSV, and then opening in text editor.

When I run it to format COM, AND run it in report caster as format COM, then it opens with text editor by default.

Thank you for your help!


Production - 7.6.4
Sandbox - 7.6.4
September 29, 2015, 09:45 AM
Doug
Whether it opens in text or Excel is up to Windows or the user. IMHO: Use the FORMAT COM, COMT, XLSX as the user intends to open it. There's no reason to use FORMAT COM and open it in Excel and saving it as CSV, that's just an extraneous step.