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] Loop to read multiple csv files

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Loop to read multiple csv files
 Login/Join
 
Platinum Member
posted
Hi,
i need a loop to read multiple csv files. The structure of the files are always the same, the only different is the name. Can i also use only one master file and replace the name with &variables???

Regards

christian

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


WF Production Version: 7.7.02M
WF Test Version: 7.7.02M
Developer Studio: 7.7.02
HTML, EXL2K, FLEX, PDF,PPT
 
Posts: 156 | Location: Essen Germany | Registered: December 02, 2010Report This Post
Master
posted Hide Post
quote:
Originally posted by ChristianP:
Hi,
i need a loop to read multiple csv files. The structure of the files are always the same, the only different is the name. Can i also use only one master file and replace the name with &variables???

Regards

christian


I did something very similar last year. Code was written before I knew WebFOCUS had a looping syntax. I still like mine better, though. ;-)

-SET &FROMDATE     = '20110401';
-SET &TODATE       = '20110403';

-SET &BEDS_IN_UNIT = '14';
-SET &DEPARTMENT   = '101926400';

-SET &MYDATE       = &FROMDATE;
-SET &DAYSTOLOOP   = (&TODATE - &FROMDATE) + 1;
-SET &ILOOPNO      = 0;


-CONTINUE
-* SET THE 'LOOP' VARS ONLY TO CALC THE LOOP DAYS
-SET &FROMDATELOOP = DATECVT(&FROMDATE, 'I8YYMD', 'YYMD');
-SET &TODATELOOP   = DATECVT(&TODATE, 'I8YYMD', 'YYMD');
-SET &DAYSTOLOOP   = DATEDIF(&FROMDATELOOP,&TODATELOOP,'D');
-SET &DAYSTOLOOP   = &DAYSTOLOOP + 1;


-*-TYPE &|FROMDATE     = &FROMDATE
-*-TYPE &|TODATE       = &TODATE
-*-TYPE &|MYDATE       = &MYDATE
-*-TYPE &|DAYSTOLOOP   = &DAYSTOLOOP
-*-EXIT



-DOLOOP3

-SET &IHMFD  = 'BTLOOP' || &ILOOPNO;



DEFINE FILE DMBEDOCCDW
	THE_DATE/YYMD      = HDATE(DATE_OCC, 'YYMD');
	MY_START_DATE/YYMD = &MYDATE;

	START_00/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 0, 8, 'HYYMDs');
	END_00/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 0, 8, 'HYYMDs');
	OCC_00/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_00 TO END_00
						OR PARENT_TO_CALC_DATETIME FROM START_00 TO END_00
						OR START_00 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_00 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_00/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_00/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_00/YYMD        = &MYDATE;
	MY_START_DATETIME_00/HYYMDS  = DT(&MYDATE 00:00:00);
	MY_END_DATE_00/YYMD          = &MYDATE;
	MY_END_DATETIME_00/HYYMDS    = DT(&MYDATE 00:59:59);
	FROM_00/HYYMDs MISSING ON = IF PARENT_DATETIME_00 LT START_00 THEN MY_START_DATETIME_00 ELSE PARENT_EFFECTIVE_TIME;
	TO_00/HYYMDs MISSING ON   = IF CHILD_DATETIME_00 GT END_00 THEN MY_END_DATETIME_00 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_00/I10    = IF OCC_00 EQ 1 THEN HDIFF(TO_00, FROM_00, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_00/D10.2         = IF OCC_00 EQ 1 THEN (SECS_IN_BED_FOR_00 / 3600) * 100 ELSE 0;


[REPEATED 23 MORE TIMES, INCREMENTING THE HOUR]

END

TABLE FILE DMBEDOCCDW
PRINT
	PAT_ENC_CSN_ID
	PAT_ID
	MY_START_DATE
	PARENT_FROM_CALC_DATETIME
	PARENT_TO_CALC_DATETIME
	OCC_00
	FROM_00
	TO_00

	OCC_00
	SECS_IN_BED_FOR_00
	UTIL_PCT_00

	OCC_01
	SECS_IN_BED_FOR_01
	UTIL_PCT_01

	OCC_02
	SECS_IN_BED_FOR_02
	UTIL_PCT_02

	OCC_03
	SECS_IN_BED_FOR_03
	UTIL_PCT_03

	OCC_04
	SECS_IN_BED_FOR_04
	UTIL_PCT_04

	OCC_05
	SECS_IN_BED_FOR_05
	UTIL_PCT_05

	OCC_06
	SECS_IN_BED_FOR_06
	UTIL_PCT_06

	OCC_07
	SECS_IN_BED_FOR_07
	UTIL_PCT_07

	OCC_08
	SECS_IN_BED_FOR_08
	UTIL_PCT_08

	OCC_09
	SECS_IN_BED_FOR_09
	UTIL_PCT_09

	OCC_10
	SECS_IN_BED_FOR_10
	UTIL_PCT_10

	OCC_11
	SECS_IN_BED_FOR_11
	UTIL_PCT_11

	OCC_12
	SECS_IN_BED_FOR_12
	UTIL_PCT_12

	OCC_13
	SECS_IN_BED_FOR_13
	UTIL_PCT_13

	OCC_14
	SECS_IN_BED_FOR_14
	UTIL_PCT_14

	OCC_15
	SECS_IN_BED_FOR_15
	UTIL_PCT_15

	OCC_16
	SECS_IN_BED_FOR_16
	UTIL_PCT_16

	OCC_17
	SECS_IN_BED_FOR_17
	UTIL_PCT_17

	OCC_18
	SECS_IN_BED_FOR_18
	UTIL_PCT_18

	OCC_19
	SECS_IN_BED_FOR_19
	UTIL_PCT_19

	OCC_20
	SECS_IN_BED_FOR_20
	UTIL_PCT_20

	OCC_21
	SECS_IN_BED_FOR_21
	UTIL_PCT_21

	OCC_22
	SECS_IN_BED_FOR_22
	UTIL_PCT_22

	OCC_23
	SECS_IN_BED_FOR_23
	UTIL_PCT_23

	BY THE_DATE
	BY BED_LABEL

WHERE DATE_OCC EQ DT(&MYDATE);
ON TABLE HOLD AS &IHMFD
END

-SET &MYDATE       = &MYDATE + 1;






-SET &ILOOPNO = &ILOOPNO + 1;

-IF &ILOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP3 ELSE GOTO DOLOOP3;
-BREAKLOOP3






-SET &JLOOPNO = 1;

TABLE FILE BTLOOP0
PRINT
*

ON TABLE HOLD AS BT_BED_OCC_BASE

-IF &JLOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP4 ELSE GOTO DOLOOP4;
-DOLOOP4



MORE
-SET &JHMFD  = 'BTLOOP' || &JLOOPNO;
FILE &JHMFD.EVAL


-SET &JLOOPNO = &JLOOPNO + 1;
-IF &JLOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP4 ELSE GOTO DOLOOP4;
-BREAKLOOP4

END


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Expert
posted Hide Post
The simple answer is Yes.

Create a loop in Dialog Manager.

In the loop use FILEDEF to allocate the csv file

TABLE FILE the contents of the file.

If combining the data, then the HOLD can be changed to SAVE, and a seconf FILEDEF for the hold can change the hold file to append mode.


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
Platinum Member
posted Hide Post
Thanks Waz and ABT, i got it, the only problem was that the dot in '.csv' was lost. I solved it by putting the '.csv' into a &variable.
 
FILEDEF &KU_NR DISK E:\TEMP\&KU_NR.csv

Like This
FILEDEF &KU_NR DISK E:\TEMP\&KU_NR&DOC


Regards

Christian


WF Production Version: 7.7.02M
WF Test Version: 7.7.02M
Developer Studio: 7.7.02
HTML, EXL2K, FLEX, PDF,PPT
 
Posts: 156 | Location: Essen Germany | Registered: December 02, 2010Report This Post
Expert
posted Hide Post
With & variables, the dot is used to concat to other variables or text.

One dot uses the rest as an index
Two dots concatenates to the variables contents
Three dots, &KU_NR...csv, See two dots.


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] Loop to read multiple csv files

Copyright © 1996-2020 Information Builders