Consider the following tweaks...
 
--Bill

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Dattatraya
Walgude
Sent: Friday, October 16, 2009 5:48 AM
To: U2 Users List
Subject: Re: [U2] Unibasic: Sample program - to extract data from Table

OPEN 'CUSTOMER' TO F.FIL ELSE  null

OPENSEQ 'OUTPUT.CSV' TO CSVFIL ELSE NULL WEOFSEQ CSVFIL SELECT FIL LOOP
WHILE READNEXT ID DO  
  READ REC FROM F.FIL, ID THEN

             NUM.ATTRS = DCOUNT(REC,@AM)
for A = 1 TO NUM.ATTRS
  MV.COUNT<1,A> = DCOUNT(REC<A>,@VM)
next A

REC<9> = OCONVS(REC<9>,"D2/")

             MAX.MVS = MAXIMUM(MV.COUNT)
FOR A = 1 TO MAX.MVS

  OUT.LINE = ''

  FOR B = 1 TO NUM.ATTRS

    begin case
          case MV.COUNT<1,A> = 1  ;  OUT.LINE<1,B> = REC<B> 
          case 1                  ;  OUT.LINE<1,B> = REC<B,A>
    end   case  

  NEXT B

          OUT.LINE = '' : CHANGE(CHANGE(OUT.LINE,@AM,','),@VM,',') :
',':ID
 WRITESEQ OUT.LINE ON CSVFIL ELSE CRT 'CAN NOT EWRITE TO CSV FILE'

NEXT A

END
REPEAT


:BASIC BP outfile

Compiling Unibasic: BP/outfile in mode 'u'.
compilation finished
:RUN BP outfile
In BP/_outfile at line 10 WARNING: UNINITIALIZED VARIABLE USED! Zero
ssumed!
:

And output is :- ( Missing C,R in multivalve, date also not converted)

Jones, Bob,123 E. 23rd St.,Arvada,CO,80276,3037768854,V4341,9611,D,7,R,6
Jones, Bob,123 E. 23rd St.,Arvada,CO,80276,3037768854,V4341,9611,D,7,R,6
Jones, Bob,123 E. 23rd St.,Arvada,CO,80276,3037768854,V4341,9611,D,7,R,6

Thanks & Regards,
Dattatraya Walgude



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Edward Brown
Sent: Friday, October 16, 2009 12:39 PM
To: U2 Users List
Subject: Re: [U2] Unibasic: Sample program - to extract data from Table

Yes, and I've just spotted the first mistake - the last line should have
been a couple of lines higher...


* Count how many multivalues are in each attribute MV.COUNT = ""
NUM.ATTRS = DCOUNT(REC,@AM)
FOR A = 1 TO NUM.ATTRS
  MV.COUNT<1,A> = DCOUNT(REC<A>,@VM)
NEXT A
* And find the highest number
MAX.MVS = MAXIMUM(MV.COUNT)
* Convert specific attributes to date format.
* Note the OCONVS handles multivalued data - it converts each value
separately.
REC<9> = OCONVS(REC<9>,"D2/")
* Now output a line for each multivalue
FOR A = 1 TO MAX.MVS
  OUT.LINE = ""
  FOR B = 1 TO NUM.ATTRS
    IF MV.COUNT<1,A> EQ 1 THEN OUT.LINE<1,B> = REC<B> ELSE OUT.LINE<1,B>
= REC<B,A>      
  NEXT B
* Turn multivalues in the output line to commas
  OUT.LINE = CHANGE(OUT.LINE,@VM,",")
* And write the line to the output file
  WRITESEQ OUT.LINE ...
NEXT A
*



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Edward Brown
Sent: 16 October 2009 08:06
To: U2 Users List
Subject: Re: [U2] Unibasic: Sample program - to extract data from Table

Dattatraya - in unibasic almost any string handling task is possible!

Hmm - funny how the original topic of this thread and the subsequent
discussion of specifications, or lack of, seems to have come full
circle.


Starting with REC - as read from disk.

Presume REC has one or more multivalued fields. REC is to be written to
the output file multiple times, subsequent lines taking the 1st, 2nd etc
multivalue where the attribute is multivalued and taking the entire
attribute otherwise.

* Count how many multivalues are in each attribute MV.COUNT = ""
NUM.ATTRS = DCOUNT(REC,@AM)
FOR A = 1 TO NUM.ATTRS
  MV.COUNT<1,A> = DCOUNT(REC<A>,@VM)
NEXT A
* And find the highest number
MAX.MVS = MAXIMUM(MV.COUNT)
* Convert specific attributes to date format.
* Note the OCONVS handles multivalued data - it converts each value
separately.
REC<9> = OCONVS(REC<9>,"D2/")
* Now output a line for each multivalue
FOR A = 1 TO MAX.MVS
  OUT.LINE = ""
  FOR B = 1 TO NUM.ATTRS
    IF MV.COUNT<1,A> EQ 1 THEN OUT.LINE<1,B> = REC<B> ELSE OUT.LINE<1,B>
= REC<B,A>      
  NEXT B
  WRITESEQ OUT.LINE ...
NEXT A
OUT.LINE = CHANGE(OUT.LINE,@VM,",")
*

Hope this helps - I've not compiled it so it might need a bit of
tweaking to get it working.

Ed



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Dattatraya
Walgude
Sent: 16 October 2009 05:20
To: U2 Users List
Subject: Re: [U2] Unibasic: Sample program - to extract data from Table

Many Thanks George

Now output is giving following way 

Jones, Bob,123 E. 23rd St.,Arvada,CO,80276,3037768854,V4341,9611,D
C
R,7,6
Frobisher, Kamal,P.O. Box 9845
,Denver,CO,80209-4444,3037780880,,,K
O,33,204


But I want following way ( D,C,R are multivalue ) , date output also
showing 9611 which is (04/24/94) is it possible?

Jones, Bob,123 E. 23rd St.,Arvada,CO,80276,3037768854,V4341,9611,D,7,6
Jones, Bob,123 E. 23rd St.,Arvada,CO,80276,3037768854,V4341,9611,C,7,6
Jones, Bob,123 E. 23rd St.,Arvada,CO,80276,3037768854,V4341,9611,R,7,6

Thanks & Regards,
Dattatraya Walgude


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of George Gallen
Sent: Thursday, October 15, 2009 6:54 PM
To: U2 Users List
Subject: Re: [U2] Unibasic: Sample program - to extract data from Table

Try first starting with:

LINE = '' : CHANGE(CHANGE(REC,@AM,','),@VM,CHAR(10)) : ',':ID

I think that the LF character might give you want you want

George

> -----Original Message-----
> From: [email protected] [mailto:u2-users- 
> [email protected]] On Behalf Of Dattatraya Walgude
> Sent: Thursday, October 15, 2009 1:59 AM
> To: U2 Users List
> Subject: Re: [U2] Unibasic: Sample program - to extract data from
Table
>
> Sorry Symeon and all for asking such silly question.
>
> I manage @ID column in output.csv in following way, now I want 
> multivalue columns in new lines with all columns (now its comes in one
> row/line)
>
> LINE = '' :  CHANGE(CHANGE(REC,@AM,','),@VM,',') :  ',':ID
>
>
> Thanks & Regards,
> Dattatraya Walgude
> DBA Team
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users



****************  Disclaimer *****************
 

 

This mail, including any attachments contains confidential and
privileged information for the sole use of the addressee(s). If you are
not the intended recipient, 

please notify the sender by e-mail and delete the original message.  Any
unauthorized review, use, disclosure, dissemination, forwarding,
printing or copying of

 this email or any action taken in reliance on this e-mail is strictly
prohibited and are unlawful. This e-mail may contain viruses. R Systems
International Limited  has 

taken every reasonable precaution to minimize this risk.  R Systems
International Limited is not liable for any damage you may sustain as a
result of any virus in this e-mail. 

Before opening the e-mail or attachment, You should carry out your own
virus checks. R Systems International Limited reserves the right to
record, monitor, and inspect

 all email communications through its internal and external networks.  R
Systems International Ltd prohibits its information systems from being
used to view, store or forward 

offensive or discriminatory material.

 

******** End of Disclaimer ********

_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

------------------------------------------------------------------------
-------------------
Please remember to recycle wherever possible. Reduce, reuse, recycle,
think do you need to print this e-mail?
------------------------------------------------------------------------
-------------------
This e-mail and any attachment(s), is confidential and may be legally
privileged. It is intended solely for the addressee. If you are not the
addressee, dissemination, copying or use of this e-mail or any of its
content is prohibited and may be unlawful. If you are not the intended
recipient please inform the sender immediately and destroy the e-mail,
any attachment(s) and any copies. All liability for viruses is excluded
to the fullest extent permitted by law. It is your responsibility to
scan or otherwise check this email and any attachment(s). Unless
otherwise stated (i) views expressed in this message are those of the
individual sender (ii) no contract may be construed by this e-mail.
Emails may be monitored and you are taken to consent to this monitoring.


Civica Services Limited, Company No. 02374268; Civica UK Limited,
Company No. 01628868 Both companies are registered in England and Wales
and each has its registered office at 2 Burston Road, Putney, London,
SW15 6AR.
------------------------------------------------------------------------
-------------------

_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users


_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to