View previous topic :: View next topic
|
Author |
Message |
Midhila Menon
New User
Joined: 10 Oct 2007 Posts: 4 Location: Bangalore
|
|
|
|
Can anyone help me in creating a comma-delimited dataset ?
Regards,
Midhila |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Comma seperated files are created when you put a comma betewen the fields.
In your REXX, simply use OVERLAY or any concatenation technique to put a comma after each field.
O. |
|
Back to top |
|
|
Midhila Menon
New User
Joined: 10 Oct 2007 Posts: 4 Location: Bangalore
|
|
|
|
Hi
Could you be please more ellaborative.
My dataset will contain fields like User id , User Name and there information.
Thanks!
Midhila |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
If you know the fields' positions, then simply:
1. Read the file using EXECIO
2. For each record, insert comma after each field
3. Write to output file using EXECIO.
O. |
|
Back to top |
|
|
akhi007
New User
Joined: 30 Jan 2006 Posts: 35 Location: Richmond
|
|
|
|
Hi,
Use can use OVERLAY function or INSERT function to insert comma after each fields.
Thanks,
Akhi |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Use can use OVERLAY function or INSERT function to insert comma after each fields. |
Not completely right, as the name implies OVERLAY will ... imagine !!!
Insert is ok, but it needs more statements ( it is an incremental approach)
better do it from last to first ( to avoid counting too much )
I would go for the much more clear concatenation of substrings
here is the sample code
Code: |
string = "user_idUser_nameOther_info"
say "string ==>" || string || "<=="
/* INSERT */
strng1 = INSERT(",",string,16)
say "string 1 ==>" || strng1 || "<=="
strng2 = INSERT(",",strng1,7)
say "string 2 ==>" || strng2 || "<=="
/* CONCATENATION (preferred) */
strngx = substr(string, 1, 7) || "," || ,
substr(string, 8, 9) || "," || ,
substr(string, 17)
say "string x ==>" || strngx || "<=="
|
note for the last string, no length specified, so it will take the rest of the string |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
If your variables have spaces between, and the fields do not contain spaces, maybe something like
Code: |
DO WHILE RCX = 0
"EXECIO 1 DISKR ddname"
RCX = RC
IF RCX = 0 THEN DO
PULL string
NEW = ''
DO A = 1 TO WORDS(string)
NEW = NEW!!WORD(string,A)!!','
END
END
END
|
|
|
Back to top |
|
|
Alan Voss
New User
Joined: 29 Nov 2006 Posts: 32 Location: Jacksonville, FL
|
|
|
|
Also, if a field (aka variable) contains a comma, that field should be enclosed in quotes (double, not single). |
|
Back to top |
|
|
Midhila Menon
New User
Joined: 10 Oct 2007 Posts: 4 Location: Bangalore
|
|
|
|
Thanks all for your replies..I will try on this and let you all know.
Midhila |
|
Back to top |
|
|
|