Focal Point
[SOLVED] Question about COMT

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

April 03, 2009, 12:20 PM
ChannyS
[SOLVED] Question about COMT
The documentation states:

"Saves the column headings in the first row of the output file. It produces 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."

However, I'm finding that only values that actually contain a comma in it get the double quotes around it. Is there some setting I need to set in order to get the double quotes around all character values?

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


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 03, 2009, 03:09 PM
mrguru
I just ran a focexec and did an on table hold format comt and the results were as stated. If the master shows the field as an alpha then it is enclosed in double quotes. I am running 7.6.4.


WF 8.2.01M
8.2.01M Reporting Server
Windows 2012 Srvr R2
PDF,Excel, HTML
Graphs - a lot of graphs
April 03, 2009, 03:24 PM
ChannyS
I am using 7.6.8. When I open in textpad it doesn't show the double quotes unless there is a comma in the data.


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 03, 2009, 03:45 PM
ChannyS
When I run the following FOCEXEC:

 
TABLE FILE CAR
PRINT CAR COUNTRY
COMPUTE FIELD_WITH_COMMA/A9 = 'HELLO,BYE';
ON TABLE PCHOLD FORMAT COMT
END
 


Save the results to a file, open the file in TextPad, this is what I get:

  

CAR,COUNTRY,FIELD_WITH_COMMA
JAGUAR,ENGLAND,"HELLO,BYE"
JENSEN,ENGLAND,"HELLO,BYE"
TRIUMPH,ENGLAND,"HELLO,BYE"
DATSUN,JAPAN,"HELLO,BYE"
TOYOTA,JAPAN,"HELLO,BYE"
ALFA ROMEO,ITALY,"HELLO,BYE"
MASERATI,ITALY,"HELLO,BYE"
AUDI,W GERMANY,"HELLO,BYE"
BMW,W GERMANY,"HELLO,BYE"
PEUGEOT,FRANCE,"HELLO,BYE"





Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 03, 2009, 04:01 PM
j.gross
COM and COMT produce CSV files.

There seems to be no published standard for CSV format, and no accepted convention for representing null values. Given that state of affairs, the product folks apparently decided to ignore the MISSING attribute, to ensure that other programs opening the csv file would not choke. Thus, the output file represents NULL by " " (for alpha fields) or 0 (for numeric or date fields).
April 03, 2009, 04:13 PM
ChannyS
Jack - I think you meant this as a response to my other post. In any case, following Susannah's idea, I can use the MISSING to get myself the NA I want. But, that brings me back to this post! If they actually would put quotes around alpha fields then my numeric fields which have turned into alphas so that I can get NA's into them will have quotes around them. :-(


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 03, 2009, 04:49 PM
j.gross
Oops.

But, joining the two posts, in 768 if you construct an alpha field (with missing=on), containing either the numeric representation of your numeric field or a suitable representation of NA, then the former will be held w/o quotes, and Excel should render the field as either a number or NA, as required. Non?


- Jack Gross
WF through 8.1.05
April 03, 2009, 05:10 PM
ChannyS
Well I guess it's a little cyclic here because I have a real alpha field that I'm expecting to always have quotes around it and that's not happening. So if that's continues working that way, then the missing field is fine (numeric or NA). However, if it works the way I expect it, then my numeric fields which need to have NA's so they are put out as Alpha's would have quotes...


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 03, 2009, 08:14 PM
jimster06
Consider using
ON TABLE HOLD FORMAT COMT
hth


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
April 04, 2009, 01:22 PM
susannah
'Hello,bye' is 1 field.
you've defined 1 field, with special characters in it, so what you got is exactly what you asked for.
you can't have a comma in the middle of a single field in a COMT unless its in quotes so that the interpreter knows its 1 field.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
April 05, 2009, 12:19 AM
ChannyS
Susannah,

My question wasn't why 'Hello,Bye' got the quotes - it was why the others didn't when the documentation says all character fields get quotes around them. So when my real field has some data with commas and some without commas, only those values with commas get the quotes. This seems to be inconsistent with the documentation unless I am misunderstanding something?


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 05, 2009, 10:53 PM
susannah
yes you are misunderstanding something.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
April 06, 2009, 08:59 AM
ChannyS
Considering that the documentation states:

It produces a variable-length text file with fields separated by commas, and with character values enclosed in double quotation marks.

Which part am I misunderstanding?


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 06, 2009, 09:34 AM
Francis Mariani
In v7.6.5 and v5.3.4, I get a file as described:

FILEDEF HTEST1 DISK baseapp/htest1.csv
TABLE FILE CAR
PRINT CAR COUNTRY
COMPUTE FIELD_WITH_COMMA/A9 = 'HELLO,BYE';
ON TABLE HOLD AS HTEST1 FORMAT COMT
END


Gives me:

"CAR","COUNTRY","FIELD_WITH_COMMA"
"JAGUAR","ENGLAND","HELLO,BYE"
"JENSEN","ENGLAND","HELLO,BYE"
"TRIUMPH","ENGLAND","HELLO,BYE"
"DATSUN","JAPAN","HELLO,BYE"
"TOYOTA","JAPAN","HELLO,BYE"
"ALFA ROMEO","ITALY","HELLO,BYE"
"MASERATI","ITALY","HELLO,BYE"
"AUDI","W GERMANY","HELLO,BYE"
"BMW","W GERMANY","HELLO,BYE"
"PEUGEOT","FRANCE","HELLO,BYE"


Perhaps a default setting has changed...

This message has been edited. Last edited by: Francis Mariani,


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
April 06, 2009, 09:40 AM
ChannyS
Francis,

You get what I would have expected.

I guess it's time for me to open a case....


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 06, 2009, 09:41 AM
Francis Mariani
Yes, I'd open a case. It works as expected in v7.6.5, v5.3.4 and v5.3.2.


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
April 06, 2009, 09:46 AM
ChannyS
Actually, when I do it as a FILEDEF it works the same way for me. But when I PCHOLD it, then save the file in Excel, that's when I get the problem. Any suggestions?


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 06, 2009, 10:09 AM
<JG>
quote:
then save the file in Excel, that's when I get the problem. Any suggestions?

Yes, do not save the file in Excel.

It is Excel that is removing the outer double quotes when it does an automatic import of a csv file.
The reason the inner ones remain is because excel does not know how to handle them.

If you want to open the file in Excel them you must use the data/import external data functionality
April 06, 2009, 11:50 AM
ChannyS
OK - thanks. I'm just trying to figure out now how to make sure this thing doesn't automatically pop up in Excel. (Even though I changed the Windows File Extension association, it is still coming up in Excel).


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv
April 06, 2009, 01:09 PM
ChannyS
OK - I had to change the rules for .xls - not COMT (thought I can't explain why), and now I get the File Open, Save, Cancel Dialog


Release: WebFOCUS 7.6.8
OS: Windows
Output formats: HTML, PDF, Excel, csv