Focal Point
[CLOSED] Reading Text file from disk

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

May 23, 2012, 03:56 AM
Kittuputtu
[CLOSED] Reading Text file from disk
I'm trying to read a Text file (CSV format) which is kept in my domain. I used below code to read the text file but it throwing below error.
Note - I havent created any MDF for employee.txt
file.

APP PATH EMPLYCONNECT
FILEDEF EMPL DISK EMPLOY/employee.txt
TABLE FILE EMPL
PRINT *
END

Error message with i run the procdure
(FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: EMPL
BYPASSING TO END OF COMMAND

Question - Can i read text/excel file without creating master file?

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


WF 7702m / Windows
May 23, 2012, 03:57 AM
Kittuputtu
a small correction in the code
APP PATH EMPLYCONNECT
FILEDEF EMPL DISK EMPLYCONNECT/employee.txt
TABLE FILE EMPL
PRINT *
END


WF 7702m / Windows
May 23, 2012, 11:09 AM
GamP
Well, if you have created a mastger file for the data you won't be able to read it with TABLE.
And that's what the error message tells you: it can't find the mdf called EMPL.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
May 23, 2012, 12:56 PM
John_Edwards
For a CSV file you can create a plain-jane master file -- one big text field per line. That should read, but then it will be up to you to parse the contents of that single field into its independent parts.

Note that in Dev Studio you can auto-generate a master file from a flat file by right-clicking in the Master Files section of an application directory and selecting New-->Upload Data File. That will parse the file for you for a first round.

If you need to absorb a differently-shaped file each time you'll have to go with the plain-jane option above. If your files will contain the same structure each time and you want to create a master file from your first one option 2 above will help you get started.

J.



May 23, 2012, 05:35 PM
Waz
Internally WebFOCUS needs a master file when you issue a TABLE FILE command.

When you issue TABLE FILE EMPL, WebFOCUS looks for the EMPL master file so it can find ouy what type of file it is. This is done by checking the suffix in the master. Then the appropriate module is loaded to read the data.

All the fields are needed as well, so WebFOCUS knows the field names and formats.


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!

May 24, 2012, 01:55 AM
Kittuputtu
Thanks for all the answers...that helped!!
If i create Master file for text/Excel, then i need to use FILEDEF command to read Text/excel file.
I wanted to know if is it possible to read text or other flat file without creating master file using FILEDEF command?


WF 7702m / Windows
May 24, 2012, 02:06 AM
Waz
What do you want to do with the data ?

You can use -READ to read the file, on line at a time, but that is into dialog manager variables.


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!

May 25, 2012, 10:03 AM
ABT
quote:
Originally posted by John_Edwards:
For a CSV file you can create a plain-jane master file -- one big text field per line. That should read, but then it will be up to you to parse the contents of that single field into its independent parts.

Note that in Dev Studio you can auto-generate a master file from a flat file by right-clicking in the Master Files section of an application directory and selecting New-->Upload Data File. That will parse the file for you for a first round.

If you need to absorb a differently-shaped file each time you'll have to go with the plain-jane option above. If your files will contain the same structure each time and you want to create a master file from your first one option 2 above will help you get started.

J.



Have to disagree with this. I have a .csv file and a master that breaks it up into "fields" for reporting.

vhs_beds.mas
FILENAME=VHS_BEDS, SUFFIX=COM     , $
  SEGMENT=VHS_BEDS, SEGTYPE=S0, $
    FIELDNAME=SERV_AREA_ID,      ALIAS=E1, USAGE=A5,    ACTUAL=A5, $
    FIELDNAME=BED_LABEL,         ALIAS=E2, USAGE=A256,  ACTUAL=A256, $
    FIELDNAME=DEPT_ABBREVIATION, ALIAS=E3, USAGE=A20,   ACTUAL=A20, $
    FIELDNAME=BED_NOTES,         ALIAS=E4, USAGE=A1000, ACTUAL=A1000, $
    FIELDNAME=BED_AVAILABILITY,  ALIAS=E5, USAGE=A1,   ACTUAL=A1, $


test.fex:
SET ASNAMES = ON
SET PCOMMA = ON

-SET &FILEPATH = '\\Server\';



-******************************************************************************
-SET &BED_FILE = 'HOSP1\BEDS.csv';
-SET &FULLFILENAME = &FILEPATH | &BED_FILE;

FILEDEF VHS_BEDS DISK "&FULLFILENAME"

TABLE FILE VHS_BEDS
PRINT
	HOSPNAME
	SERV_AREA_ID
	BED_LABEL
	DEPT_ABBREVIATION
	BED_NOTES
	BED_AVAILABILITY

	BY DEPT_ABBREVIATION NOPRINT
	BY BED_LABEL NOPRINT

END


-ABT


------------------------------------
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
May 27, 2012, 05:32 PM
Waz
quote:
Have to disagree with this. I have a .csv file and a master that breaks it up into "fields" for reporting


What John is talking about is a generic master to read flat files, then the individual program can break up the line into fields.


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!

May 29, 2012, 09:33 AM
Danny-SRL
So, you want a general purpose master for a sequential file.
You can create the MASTER in memory and then execute a FOCEXEC using the MASTER:

  
-* Master
EX -LINES 4 EDAPUT MASTER,GNRL,C,MEM
FILENAME=gnrl, SUFFIX=FIX     , $
  SEGMENT=GNRL, SEGTYPE=S0, $
    FIELDNAME=GNRL, ALIAS=GNRL, USAGE=A250, ACTUAL=A250, $
-RUN
-* Focexec
FILEDEF GNRL DISK app/file.txt
TABLE FILE GNRL
PRINT 
     GNRL
END

If A250 is not enough, make it bigger.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF