Creating a Flat File / CSV File

Archive of postings to DataStageUsers@Oliver.com. This forum intended only as a reference and cannot be posted to.

Moderators: chulett, rschirm

Locked
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Creating a Flat File / CSV File

Post by admin »

Hello all,

Does anyone know how to create a flat file (CSV) in universe basic code, which will then have data written to it.


Thanks
Shaun
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Hi Shaun

I attached some code

This source code is for reading from CSV File.

and Lets modify READSEQ ==> WREITESEQ

If you have trouble, refer to HELP BASIC (on TCL Mode)


Daehwan kim, Seoul

**************************************************
*
**************************************************
$INCLUDE UNIVERSE.INCLUDE INFO_ERRS.H

OPENSEQ "/data/DW/init/VISA.csv" TO FILE ELSE ABORT
LOOP
READSEQ A FROM FILE THEN
FMVAL = Field(A,",",1)
TOVAL = Field(A,",",2)
CMD = "INSERT INTO HSELSE(SYSTEM,DOMAIN,FROMVAL,TOVAL) VALUES(VISA,A0023,":FMVAL:",":TOVAL:");"
EXECUTE CMD RTNLIST VARLIST1
END
UNTIL STATUS() 0
REPEAT
CLOSESEQ FILE




----- Original Message -----
From: "Jackson, Shaun"
To:
Sent: Tuesday, March 06, 2001 2:51 PM
Subject: Creating a Flat File / CSV File


> Hello all,
>
> Does anyone know how to create a flat file (CSV) in universe basic
> code, which will then have data written to it.
>
>
> Thanks
> Shaun
>
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

You will get many replies to this one!

To create the file you need only to open it with OPENSEQ, then write to it with WRITESEQ (when you are done, close it with CLOSESEQ, since OPENSEQ locks it for update). If you want to force its creation, you can use CREATE after the file is opened.

If the file already exists, OPENSEQ will take its THEN clause. You can truncate the file using WEOFSEQ, or you can position to end-of-file ready to append, using SEEK filevariable,0,2 If the file does not already exist, OPENSEQ will take its ELSE clause and the STATUS() function will return 0. [If STATUS() is not zero, the file could not be opened for some other reason, such as you are trying to open a directory.]

Consult the BASIC manual (basic.pdf) for the exact syntax of each of the statements referred to above. The BASIC manual installs with your DataStage client software. Or enrol on the course "Programming with DataStage BASIC" - this is scheduled soon in both Sydney and Melbourne.

-----Original Message-----
From: Jackson, Shaun [mailto:Shaun.Jackson@team.telstra.com]
Sent: Tuesday, 06 March 2001 13:52
To: informix-datastage@oliver.com
Subject: Creating a Flat File / CSV File


Hello all,

Does anyone know how to create a flat file (CSV) in universe basic code, which will then have data written to it.


Thanks
Shaun
Locked