Try changing

    IF MV.COUNT<1,A> EQ 1 THEN OUT.LINE<1,B> = REC<B> ELSE OUT.LINE<1,B> = 
REC<B,A>

To

    IF MV.COUNT<1,B> EQ 1 THEN OUT.LINE<1,B> = REC<B> ELSE OUT.LINE<1,B> = 
REC<B,A>

-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Dattatraya Walgude
Sent: 16 October 2009 12:17
To: U2 Users List
Subject: Re: [U2] Unibasic: Sample program - to extract data from Table

Now Date is converted, but multivalue ( C , R  ) still missing.

,Jones, Bob,123 E. 23rdst.,Arvada,CO,80276,3037768854,V4341,04/24/94,D,7,R,6
,Jones, Bob,123 E. 23rdSt.,Arvada,CO,80276,3037768854,V4341,04/24/94,D,7,R,6
,Jones, Bob,123 E. 23rdSt.,Arvada,CO,80276,3037768854,V4341,04/24/94,D,7,R,6


Thanks & Regards,
Dattatraya Walgude


-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Edward Brown
Sent: Friday, October 16, 2009 3:29 PM
To: U2 Users List
Subject: Re: [U2] Unibasic: Sample program - to extract data from Table

Dattatraya,

(Possible) correction added.

You really need to take the time to understand the example code we're giving 
you. There will still be problems in the code below - for example, I can't see 
why the date conversion is failing or why (despite the uninit var) the C and R 
are missing.

Really at this point you are in the best position to debug the program as you 
have the source data, which I'm having to guess the format of.

Debugging - there's a proper debugger built into unidata but for quick and 
dirty checking, use

CRT variable

to display the contents of a variable to screen, and

INPUT X,1

to have the program wait until you press a key - useful if you're displaying a 
lot of values and want to add a pause - for example after each record has been 
processed.

Ed



OPEN 'CUSTOMER' TO FIL ELSE STOP 201 'CUSTOMER'
OPENSEQ 'OUTPUT.CSV' TO CSVFIL ELSE NULL
WEOFSEQ CSVFIL
SELECT FIL
LOOP WHILE READNEXT ID DO
 READ REC FROM FIL,ID THEN
* Count how many multivalues are in each attribute MV.COUNT = ""
NUM.ATTRS = DCOUNT(REC,@AM)
MV.COUNT = ""
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,",")
OUT.LINE = '' : CHANGE(CHANGE(OUT.LINE,@AM,','),@VM,',') : ',':ID
* And write the line to the output file
 WRITESEQ OUT.LINE ON CSVFIL ELSE CRT 'CAN NOT EWRITE TO CSV FILE'
 * WRITESEQ OUT.LINE ...
NEXT A
END
REPEAT
==End code


: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: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
> boun...@listserver.u2ug.org] 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
U2-Users@listserver.u2ug.org
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
U2-Users@listserver.u2ug.org
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
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to