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     [SOLVED] GETTOK getting wrong values from csv File

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] GETTOK getting wrong values from csv File
 Login/Join
 
Member
posted
Hi!

I am using GETTOK to get the date field from a csv file and print it in another file, the result is not consistent

The code I am using is:
DAT1/A20 =GETTOK(LINE1,512,11,'"',19,'A20');
WDDAY/A8 = EDIT(DAT1,'9999$99$99$$$$$$$$');

The date format in the csv file is "yyyy/mm/dd hh:mm:ss" and I am storing it as "YYYYMMSS" in another file, however the out come it "mosty" correct. i.e. if the date is 2014/06/04 I get the following results :

DATE CNT
---- ---
2 2
201 1
2014 3
20140 2
201406 1
20140604 143

The errors are in random lines with no clear pattern as why it's happening.

Any ideas?

Many Thanks

Fady

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


Webfocus 7.7, Windows
 
Posts: 6 | Registered: June 05, 2014Report This Post
Expert
posted Hide Post
You seem to be getting the 11th token, is that correct ?

What is the values of LINE1 ?


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
Member
posted Hide Post
Yes the 11th Token, I am processing the csv file line by line.
An example of the line:
"Attendo WEWABM";"Kronoby fortsätter med Attendo";"ATTENDOWEWABM130266143";;"Svenska YLE - Yle Fem - Radio Vega";"http://svenska.yle.fi/artikel/2014/06/04/kronoby-fortsatter-med-attendo";"2014/06/04 17:04:00";"Kronoby fortsätter med AttendoPublicerad 04.06.2014 - 16:05.Arkivbild. Dalsbruks hälsostation Bild: YLE/ Tiina GrönroosKronoby hälsocentraler fortsätter med läkare från Attendo.På sikt är tanken att gå över till egna läkare, men ännu klarar man inte det. Därför går social- och..."

In General the token is fetched correctly, in random occasions it's not. I couldn't find any problem in the lines that generated the error.


Webfocus 7.7, Windows
 
Posts: 6 | Registered: June 05, 2014Report This Post
Expert
posted Hide Post
I would suggest using the CSV delimiter to get the token. ";".

I think it is safer to do it that way. Assuming that there are no delimiters within the text.

It may also be safer to write a master file to read the CSV as data and not a single line.


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
Member
posted Hide Post
Waz;

Thank you for your reply and please bare with me as I am still VERY green with WebFocus.

I am using the the quotation mark as I thought it would be safer in case the file came with a comma instead of the semi colon, and it would make it easier to handle the token without the extra quotation mark to ignore.

I am not sure what you mean with the master file, I am using my code to generate a "master" file that will be processed and added to a database.

All the fields seem to be fetched normally, the only field I am having an issue with is the date.

SET MORE=OFF, MSG=OFF

FILEDEF WWDAT DISK C:\IBI\APPS\ESMERK\WEWADAT.CSV (LRECL 512
-RUN

DEFINE FILE WWDAT
APUPROJ/A35 =GETTOK(LINE1,512,1,'"',35,APUPROJ);
PROJECT/A35 =GETTOK(APUPROJ,35,1,'_',35,PROJECT);
HEADLINE/A80 =GETTOK(LINE1,512,3,'"',80,HEADLINE);
WDATID/A35 =GETTOK(LINE1,512,5,'"',35,WDATID);
SOURCE/A30 =GETTOK(LINE1,512,7,'"',30,SOURCE);
DAT1/A20 =GETTOK(LINE1,512,11,'"',19,'A20');
WDDAY/A8 = EDIT(DAT1,'9999$99$99$$$$$$$$');
END
TABLE FILE WWDAT
SUM CNT.APUPROJ AS 'CNT'
BY WDDAY AS 'DATE'


Webfocus 7.7, Windows
 
Posts: 6 | Registered: June 05, 2014Report This Post
Expert
posted Hide Post
What I am saying is that it may be esier for you to use the master file to read the csv as a csv.

e.g.
EX -LINES * EDAPUT MASTER,test,CV,FILE
FILENAME=test, SUFFIX=DFIX,$
SEGNAME=test, $
  FIELD=FIELD1 ,ALIAS=  ,A255 ,A255 ,$
  FIELD=FIELD2 ,ALIAS=  ,A255 ,A255 ,$
  FIELD=FIELD3 ,ALIAS=  ,A255 ,A255 ,$
  FIELD=FIELD4 ,ALIAS=  ,A255 ,A255 ,$
  FIELD=FIELD5 ,ALIAS=  ,A255 ,A255 ,$
  FIELD=FIELD6 ,ALIAS=  ,A255 ,A255 ,$
  FIELD=FIELD7 ,ALIAS=  ,A21,A21 ,$
  FIELD=FIELD8 ,ALIAS=  ,A500,A500,$
EDAPUT*

EX -LINES * EDAPUT ACCESS,test,CV,FILE
SEGNAME=test, DELIMITER=;, HEADER=NO, $
EDAPUT*

FILEDEF TEST DISK test.ftm

-RUN

-WRITE TEST "Attendo WEWABM";"Kronoby fortsätter med Attendo";"ATTENDOWEWABM130266143";;"Svenska YLE - Yle Fem - Radio Vega";"http://svenska.yle.fi/artikel/2014/06/04/kronoby-fortsatter-med-attendo";"2014/06/04 17:04:00";"Kronoby fortsätter med AttendoPublicerad 04.06.2014 - 16:05.Arkivbild. Dalsbruks hälsostation Bild: YLE/ Tiina GrönroosKronoby hälsocentraler fortsätter med läkare från Attendo.På sikt är tanken att gå över till egna läkare, men ännu klarar man inte det. Därför går social- och..."

-RUN
TABLE FILE TEST
PRINT
FIELD1
FIELD2
FIELD3
FIELD4
FIELD5
FIELD6
COMPUTE DATE/A8 = EDIT(FIELD7,'$9999$99$99') ;
FIELD8
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
Expert
posted Hide Post
[quote]

FILE=TEST, SUFFIX=DFIX
SEGNAME=TEST, SEGTYPE=S0, $
FIELD=FIELD1 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD2 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD3 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD4 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD5 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD6 ,ALIAS= ,A255 ,A255 ,$
FIELD=FIELD7 ,ALIAS= ,A21,A21 ,$
FIELD=FIELD8 ,ALIAS= ,A500,A500,$
FIELDNAME=DELIMITER ,ALIAS=';' ,USAGE=A1 ,ACTUAL=A1 ,$

the double quotes are fine.
just write a master file that says, this is a delimited file and the delimiter is a semicolon.
so i've tweaked waz's code above
then just pull the field that is supposed to be a date. and work on it alone. Left adjust it, measure its length (ARGLEN function), etc...




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Member
posted Hide Post
Waz, Susannah

thank you very much, works like a charm.

is there a way to get the computed field (date) in a variable to use in different places in the report?

Fady


Webfocus 7.7, Windows
 
Posts: 6 | Registered: June 05, 2014Report This Post
Expert
posted Hide Post
fady, not sure what you mean.
is 'the report' to be made from this .csv file?
or are you just grabbing the date from this .csv file and then using it in some other report?
if so, sure. but confirm first before i contine.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Member
posted Hide Post
Hi Susannah,

I am grabbing the data from the cvs to generate another report. I was having a problem with the GETTOK as in some instances it was getting truncated dates. The master file approach seems to solve the issue, however I lost the variable that had the date inside and I was using in other parts of the report.


Webfocus 7.7, Windows
 
Posts: 6 | Registered: June 05, 2014Report This Post
Expert
posted Hide Post
Was the original variable an amper variable ?

Can you post the original code ?


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
Member
posted Hide Post
Hi Waz;

the original code:
FILEDEF WWDAT DISK C:\IBI\APPS\ESMERK\WEWADAT.CSV (LRECL 512
-RUN

DEFINE FILE WWDAT
APUPROJ/A35 =GETTOK(LINE1,512,1,'"',35,APUPROJ);
PROJECT/A35 =GETTOK(APUPROJ,35,1,'_',35,PROJECT);
HEADLINE/A80 =GETTOK(LINE1,512,3,'"',80,HEADLINE);
WDATID/A35 =GETTOK(LINE1,512,5,'"',35,WDATID);
SOURCE/A30 =GETTOK(LINE1,512,7,'"',30,SOURCE);
DAT1/A26 =GETTOK(LINE1,512,11,'"',26,DAT1);
DT_FROM_ALPHA/HYYMDS = HINPUT(26, DAT1, 8, 'HYYMDS');
WDDAY/A8 = HCNVRT(DT_FROM_ALPHA,'(HYYMD)',8, 'A8');
END


TABLE FILE WWDAT
SUM CNT.APUPROJ AS 'CNT'
BY WDDAY AS 'DATE'
HEADING
"***** WEWADAT.CSV MATERIAL BY DATE *****
" "
END
-RUN
TABLE FILE WWDAT
PRINT PROJECT WDDAY SOURCE HEADLINE
BY WDATID
BY PROJECT NOPRINT
IF WDATID NE ' '
IF WDDAY NE ' '
ON TABLE SAVE
END
-RUN

So as you see I am using the WDDAY in another file as a sum and then as a field


Webfocus 7.7, Windows
 
Posts: 6 | Registered: June 05, 2014Report This Post
Expert
posted Hide Post
You can still do something similar to what you are doing now.
EX -LINES * EDAPUT MASTER,WWDAT,CV,FILE
FILENAME=WWDAT, SUFFIX=DFIX,$
SEGNAME=WWDAT, $
  FIELD=APUPROJ,ALIAS=  ,A35 ,A35 ,$
  FIELD=HEADLINE,ALIAS=  ,A80 ,A80 ,$
  FIELD=WDATID,ALIAS=  ,A35 ,A35 ,$
  FIELD=SOURCE,ALIAS=  ,A30 ,A30 ,$
  FIELD=FIELD5 ,ALIAS=  ,A255 ,A255 ,$
  FIELD=FIELD6 ,ALIAS=  ,A255 ,A255 ,$
  FIELD=DAT_FROM,ALIAS=  ,A21,A21 ,$
  FIELD=FIELD8 ,ALIAS=  ,A500,A500,$
  FIELDNAME=DELIMITER ,ALIAS=';' ,USAGE=A1 ,ACTUAL=A1 ,$
EDAPUT*

FILEDEF WWDAT DISK test.ftm

-RUN

-WRITE WWDAT "Attendo WEWABM";"Kronoby fortsätter med Attendo";"ATTENDOWEWABM130266143";;"Svenska YLE - Yle Fem - Radio Vega";"http://svenska.yle.fi/artikel/2014/06/04/kronoby-fortsatter-med-attendo";"2014/06/04 17:04:00";"Kronoby fortsätter med AttendoPublicerad 04.06.2014 - 16:05.Arkivbild. Dalsbruks hälsostation Bild: YLE/ Tiina GrönroosKronoby hälsocentraler fortsätter med läkare från Attendo.På sikt är tanken att gå över till egna läkare, men ännu klarar man inte det. Därför går social- och..."

-RUN

DEFINE FILE WWDAT
PROJECT/A35 =GETTOK(APUPROJ,35,1,'_',35,PROJECT);
WDDAY/A8 = EDIT(DAT_FROM,'$9999$99$99') ;
END

TABLE FILE WWDAT
SUM CNT.APUPROJ AS 'CNT'
BY WDDAY AS 'DATE'
HEADING
"***** WEWADAT.CSV MATERIAL BY DATE *****
" "
END
-RUN
TABLE FILE WWDAT
PRINT PROJECT WDDAY SOURCE HEADLINE
BY WDATID
BY PROJECT NOPRINT
IF WDATID NE ' '
IF WDDAY NE ' '
ON TABLE SAVE
END
-RUN


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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] GETTOK getting wrong values from csv File

Copyright © 1996-2020 Information Builders