Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Enclosing numbers within double quotes in CSV file

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Enclosing numbers within double quotes in CSV file
 Login/Join
 
Silver Member
posted
I am creating a CSV file out of Webfocus 7.6.9. Except for the numeric columns, the rest are all enclosed within double quotes. I am using COMT format.

Can any of you kindly let me know what should I have to do if i want even the numeric fields also to be enclosed within double quotes in the generated CSV file.

Please note the columns I choose in the SELECT clause is dynamic and thereby i wouldnt know the datatype of the column before itself.

This message has been edited. Last edited by: Kerry,
 
Posts: 31 | Registered: October 26, 2006Report This Post
Expert
posted Hide Post
You could convert the number to text before writing to the CSV file.

You will have to determine the format of the column first.

This can be done by either:
1. Check SYSCOLUM to get the format for thereturned hold file.
2. Use CHECK FILE ... HOLD to get the columns and formats.

With the list of columns and formats you can use DM to build computes in the TABLE...HOLD FORMAT COMT.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Silver Member
posted Hide Post
quote:
With the list of columns and formats you can use DM to build computes in the TABLE...HOLD FORMAT COMT


Waz,

we could read the file format but how can we replace the numeric data-type to alpha. So that we can get format to text file where all the numeric values converted to alpha with double-quotes.


WebFOCUS 8.1.03
Windows, Linux All Outputs
 
Posts: 46 | Location: India | Registered: August 18, 2011Report This Post
Platinum Member
posted Hide Post
I would suggest reading the "Using Functions" book. Look up

EDIT
FTOA
PTOA

Those three should cover everything you need.


Robert F. Bowley Jr.
Owner
TaRa Solutions, LLC

In WebFOCUS since 2001
 
Posts: 132 | Location: Gadsden, Al | Registered: July 22, 2005Report This Post
Expert
posted Hide Post
Except if there are any dates.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Silver Member
posted Hide Post
Hi,

I could read the integers and format it to alpha. But when I retrieve the data to Text file using COMMA, I see spaces in between quotes, this is due to specifying the alpha format to A50.
In between the code I couldn't use Trim function. Could you please help me in removing spaces by using Trim function or STRREP.



  
CHECK FILE CAR HOLD AS H1
-RUN
DEFINE FILE H1
FLAG/D2 = IF FORMAT OMITS 'A' THEN 1 ELSE 0;
END
 
TABLE FILE H1
PRINT
FIELDNAME
-*WHERE FIELDNAME EQ 'COUNTRY' OR 'CAR' OR 'SALES' OR 'DEALER_COST'
WHERE FLAG EQ 1
ON TABLE SAVE AS H1_SAVE
END
 
-RUN
-SET &RECS1 = &LINES ;
-SET &CNTR1 = 0;
-REPEAT :ENDREP1 &RECS1 TIMES
-SET &CNTR1 = &CNTR1+1;
-READ H1_SAVE &FLD_NM.&CNTR1.A66
-*-TYPE &FLD_NM.&CNTR1
-SET &NAME.&CNTR1 =&FLD_NM.&CNTR1 ||'_A';
-TYPE &NAME.&CNTR1
-:ENDREP1
-TYPE VALUE IS &FLD_NM1
-TYPE LOOP_CNT IS &RECS1
-RUN
 
TABLE FILE H1
PRINT
FORMAT
-*WHERE FIELDNAME EQ 'COUNTRY' OR 'CAR' OR 'SALES' OR 'DEALER_COST'
WHERE FLAG EQ 1
ON TABLE SAVE AS H2_SAVE
END
-RUN
-SET &RECS2 = &LINES ;
-SET &CNTR2 = 0;
-REPEAT :ENDREP2 &RECS2 TIMES
-SET &CNTR2 = &CNTR2+1;
-READ H2_SAVE &FMT.&CNTR2.A8
-TYPE &FMT.&CNTR2
-:ENDREP2
-TYPE VALUE IS &FMT1
-TYPE LOOP_CNT IS &RECS2
-RUN
 
 
 
 
-SET &CNTR3 = 0;
DEFINE FILE CAR
-REPEAT :ENDREP3 &RECS1 TIMES
-SET &CNTR3 = &CNTR3+1;
&NAME.&CNTR3/A50 = FTOA(&FLD_NM.&CNTR3, '(&FMT.&CNTR2)', &NAME.&CNTR3);
-:ENDREP3
END
-SET &CNTR4 = 0;
TABLE FILE CAR
PRINT
-REPEAT :ENDREP4 &RECS1 TIMES
-SET &CNTR4 = &CNTR4+1;
&NAME.&CNTR4
 
-:ENDREP4
-*ON TABLE SAVE
ON TABLE PCHOLD FORMAT COMMA
END


WebFOCUS 8.1.03
Windows, Linux All Outputs
 
Posts: 46 | Location: India | Registered: August 18, 2011Report This Post
Expert
posted Hide Post
The issue will be the A50.

Here is something a little simpler you may be able to use.

CHECK FILE CAR HOLD AS CARFIELDS
-RUN

TABLE FILE CARFIELDS
PRINT COMPUTE CODE/A258 = IF EDIT(FORMAT,'9') EQ 'A' THEN FIELDNAME ELSE 'COMPUTE A_' || FIELDNAME || '/A' || EDIT(EXLEN) || '=FTOA(' || FIELDNAME || ',''(' || FORMAT || ')'',A_' || FIELDNAME || ');' ;
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS FEX_FIELDS
END
-RUN

TABLE FILE CAR
PRINT
-INCLUDE FEX_FIELDS
ON TABLE PCHOLD FORMAT COMMA
END


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Silver Member
posted Hide Post
Yes, this resolves our issue. You made our life easy and simple.. Big Grin

You are truly awesome and genius. Cool
Thanks for all your help.


WebFOCUS 8.1.03
Windows, Linux All Outputs
 
Posts: 46 | Location: India | Registered: August 18, 2011Report This Post
Expert
posted Hide Post
Oh dear, I think I'm getting a BIG HEAD.....


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
Not wishing to steal Waz's thunder, but you will need a slight change to the CODE evaluation for integers -

PRINT COMPUTE CODE/A258 = IF EDIT(FORMAT,'9') EQ 'A' THEN FIELDNAME
                     ELSE IF EDIT(FORMAT,'9') EQ 'I' THEN 'COMPUTE A_' || FIELDNAME ||'/A' || EDIT(EXLEN) || '=TRIM(''L'', EDIT(' || FIELDNAME || '), ' || EDIT(EXLEN) || ', ''0'',' || EDIT(EXLEN) || ', A_' || FIELDNAME || ');'
                     ELSE 'COMPUTE A_' || FIELDNAME || '/A' || EDIT(EXLEN) || '=FTOA(' || FIELDNAME || ',''(' || FORMAT || ')'',A_' || FIELDNAME || ');' ;

Of course you may find other formats that you need to cater for differently, but the important thing is Waz has given you an excellent starting point from which to build.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
Aaahhh,

Big head deflated, thanks Tony, I needed that.

Big Grin


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
Waz,

You supplied the boat and the rod, all I did was apply a little caulking!

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Enclosing numbers within double quotes in CSV file

Copyright © 1996-2020 Information Builders