Focal Point
Issues with delimited file
April 24, 2008, 12:57 PM
DKWANIssues with delimited file
Our users frequently request ',' delimited file from us; however, the standard format from webfocus does not handle that correctly.
I would like to ask your assistance for a way easily using the standard option from webfocus and generate a file for my users. Please advice.
Currently, we have to do the file with following codes, but there will be some problem if it is a large number of output fields.
DEFINE FILE FILEO
REC1/A136=ID||(',' | NAME)||(','|SMAL_EMAIL_ADDRESS)||(','|PHONE2);
END
Output will be like-
id,name,emailaddr,phone ---no " is needed
Prod: WebFOCUS 7.1.1 CGI - Self Service - Report Caster,Win2000/IIS
Output: HTML, Excel 2000 and PDF
April 24, 2008, 01:27 PM
GlendaI'm not sure what you are asking.
FORMAT LOTUS will give you a comma delimited file as will FORMAT COMMA.
FORMAT COMT will give you a comma delimited file where the first line contains the column headings.
Glenda
In FOCUS Since 1990
Production 8.2 Windows
April 24, 2008, 01:39 PM
DKWANThe comm format comes back with a " around the alpha fields, but what the user wants is just , instead.
for example-
namelast, name first, age, mm/dd/yy, 9999
instead of
"namelast", "name first", age, "mm/dd/yy", 9999
Prod: WebFOCUS 7.1.1 CGI - Self Service - Report Caster,Win2000/IIS
Output: HTML, Excel 2000 and PDF
April 24, 2008, 01:53 PM
Francis MarianiThe reason for double-quotes is that you could have data with commas in it (e.g. a Company Name could be Johnson, Johnson and Jackson) and you wouldn't be able to differentiate between a comma to separate the columns and a comma in the data.
If you're not worried about that, you could do this:
FILEDEF H1 DISK apptest/H1.TXT
TABLE FILE CAR
PRINT
COUNTRY
COMPUTE COMM1/A1 = ',';
CAR
COMPUTE COMM2/A1 = ',';
MODEL
ON TABLE HOLD AS H1 FORMAT ALPHA
END
The output file will look something like this:
ENGLAND ,JAGUAR ,V12XKE AUTO
JAPAN ,DATSUN ,B210 2 DOOR AUTO
JAPAN ,TOYOTA ,COROLLA 4 DOOR DIX AUTO
ITALY ,ALFA ROMEO ,2000 4 DOOR BERLINA
W GERMANY ,BMW ,2002 2 DOOR
W GERMANY ,BMW ,2002 2 DOOR AUTO
W GERMANY ,BMW ,3.0 SI 4 DOOR
FRANCE ,PEUGEOT ,504 4 DOOR
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 24, 2008, 02:01 PM
DKWANThanks Francis. We are currently using this method. We use the || to eliminate the trailing spaces (which is important for our file size and for FTP purpose).
I hope there is a way from webfocus we just need to issue ON TABLE PCHOLD etc.
Prod: WebFOCUS 7.1.1 CGI - Self Service - Report Caster,Win2000/IIS
Output: HTML, Excel 2000 and PDF
April 24, 2008, 03:08 PM
LeahI'd be curious what the ouput is to be used for, but to pull out all extra blanks, your build a string may be the 'best' solution, however 'bad' it is.
Leah
April 24, 2008, 03:48 PM
JimRiceI've created a tab delimited file and then used a perl script within my focexec to create a csv file. If you have perl installed on your webfocus server and you want to see an example, let me know.
Jim
WF DevStu 5.2.6/WF Srv 5.2.4/Win NT 5.2
April 24, 2008, 04:32 PM
DKWANThanks. We don't have perl, but I guess you gave me an idea.
I'll read the csv file back and change tab to , using focus routine.
Prod: WebFOCUS 7.1.1 CGI - Self Service - Report Caster,Win2000/IIS
Output: HTML, Excel 2000 and PDF
April 25, 2008, 09:00 AM
GrayI don't know if this will help, but I developed a routine which takes a spreadsheet and creates a .MAS file so it's FOCUS-readable. The routine isn't 100% perfect, but it saves ME lots of tedious time trying to build a .MAS from scratch.
It uses good old green-screen FOCUS and Dialogue Manager.
April 25, 2008, 11:51 AM
DKWANThanks for your reply. Excel will be helpful.
Prod: WebFOCUS 7.1.1 CGI - Self Service - Report Caster,Win2000/IIS
Output: HTML, Excel 2000 and PDF