Focal Point
Generating CSV files as ouput

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

May 19, 2006, 05:53 AM
<Aparna>
Generating CSV files as ouput
Hi,
I have a .fex file which generates Excel file. I want to know what changes need to be done to generate CSV files. I tried specifying output type as COMMA but it printed the output in Explorere itself. Please do help me wih this
May 19, 2006, 07:38 AM
codermonkey
Trying changing from
ON TABLE PCHOLD AS whatever FORMAT COMMA
to
ON TABLE HOLD AS whatever FORMAT COMMA

I'm assuming you've got a FILEDEF for the file...

Let me know if it works.
May 19, 2006, 09:01 AM
<Aparna>
thanks for your reply. But I am not able to apply it to my .fex. Kindly go through my code below and let me know where I can incorporte the changes you have suggested.


In my .fex file I have an Inline query like

SELECT * from tab1;

TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS myhold
END


TABLE FILE myhold
PRINT
fld1
fld2

BY HIGHEST fld3 NOPRINT
BY fld4 NOPRINT

ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE SET ONLINE-FMT EXL2K
END


now how to change this file to get CSV files?
May 19, 2006, 09:57 AM
Prarie
change
ON TABLE SET ONLINE-FMT EXL2K

to
ON TABLE HOLD AS whatever FORMAT COMMA

And as Codermonkey said...filedef the file.


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
FILEDEF HOLDINGS DISK C:\REP

SQL SQLORA SET SERVER SER1
SQL SQLORA
SELECT * from tab1;

TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS myhold
END


TABLE FILE myhold
PRINT
fld1
fld2

BY HIGHEST fld3 NOPRINT
BY fld4 NOPRINT

ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE HOLD AS myhold FORMAT COMMA
END

I did this and it gives the error:

(FOC1517) UNRECOGNIZED COMMAND null
0 NUMBER OF RECORDS IN TABLE= 28 LINES= 28
0 NUMBER OF RECORDS IN TABLE= 28 LINES= 28
I get the FOC1517 error message alot and just ignore it. It's complaining about something but doesn't have any effect on your focexec. It looks like your code created a temporary hold file named myhold.prn containing 28 records. You then need to copy that file somewhere or use a filedef to place it where you want. I create .csv files using FORMAT COMT (this includes titles) or FORMAT COM (no titles) and then use a copy command to copy the file to a network drive.

Here's an example using the CAR file:
----------------------------------------------------
TABLE FILE CAR
PRINT
CAR
BY COUNTRY
ON TABLE HOLD AS FORUM859 FORMAT COMT
END
-*
CMD COPY FORUM859.* \\some\network\drive\forum
----------------------------------------------------

Here's the messages returned: (I ignore the FOC1517 message)
----------------------------------------------------
(FOC1517) UNRECOGNIZED COMMAND null
0 NUMBER OF RECORDS IN TABLE= 10 LINES= 10
forum859.csv
forum859.mas
2 file(s) copied.
----------------------------------------------------

Here's the contents of forum859.csv in directory \\some\network\drive\forum
----------------------------------------------------
"COUNTRY","CAR"
"ENGLAND","JAGUAR"
"ENGLAND","JENSEN"
"ENGLAND","TRIUMPH"
"FRANCE","PEUGEOT"
"ITALY","ALFA ROMEO"
"ITALY","MASERATI"
"JAPAN","DATSUN"
"JAPAN","TOYOTA"
"W GERMANY","AUDI"
"W GERMANY","BMW"
---------------------------------------------------

Here's the contents of forum859.mas in directory \\some\network\drive\forum
---------------------------------------------------
FILE=FORUM859 ,SUFFIX=COMT
SEGNAME=FORUM859,SEGTYPE=S01
FIELDNAME =COUNTRY ,E01 ,A10 ,A10 ,$
FIELDNAME =CAR ,E02 ,A16 ,A16 ,$
---------------------------------------------------

Hope this helps.
Jim


WF DevStu 5.2.6/WF Srv 5.2.4/Win NT 5.2
Aparna, on that last sample you submitted, change the statement:

ON TABLE HOLD AS myhold FORMAT COMMA

to

ON TABLE HOLD AS HOLDINGS FORMAT COMMA

I use an older version of Focus and use FORMAT LOTUS for this, but if COMMA is valid, then this should work.
I tried the following:

TABLE FILE CAR
PRINT
CAR
BY COUNTRY
ON TABLE HOLD AS FORUM859 FORMAT COMT
END
-*
CMD COPY FORUM859.* C:\TEMP\BRIO

Message given is:


0 NUMBER OF RECORDS IN TABLE= 10 LINES= 10
(FOC1569) SYSTEM COMMANDS DISABLED. CAN NOT EXECUTE cmd COPY FORUM859.*
C:\TEMP\BRIO



No files were written in teh path specified. My IBI version is : 524
Aparna,

Try using a FILEDEF command as follows:

FILEDEF FORUM859 DISK \\some\network\drive\forum\forum859_test.csv
-*
TABLE FILE CAR
PRINT
CAR
BY COUNTRY
ON TABLE HOLD AS FORUM859 FORMAT COMT
END

Jim


WF DevStu 5.2.6/WF Srv 5.2.4/Win NT 5.2