|
-
Jun 16th, 2006, 11:46 PM
#1
Thread Starter
Member
sorting and merging of 2 sequnetial files
Hello
Pl Help me with this simple solution
I want to merge two files How can i do it ?
VB Code:
OPEN "ADD.DAT" FOR INPUT AS#1
DO UNTIL EOF(1)
i% =i% + 1
if i% > ubound(Names$) then redim preserve Names$(1 to i%)
if i% > ubound(goals$) then redim preserve add$(1 to i%)
INPUT #1, Name$(i%), add$(i%)
LOOP
CLOSE #1
Which displays
"Ronaldo","Brazil"
"David","UK"
"Pele","Brazil"
"Mardona","Argentina"
"Doanald","SA"
"Schnider","Germany"
VB Code:
OPEN "Goals.Dat" FOR INPUT AS#1
DO UNTIL EOF(1)
s$=s%+1
if s% > ubound(Names$) then redim preserve Names$(1 to s%)
if s% > ubound(goals$) then redim preserve goals$(1 to s%)
INPUT #1, Names$(i%), goals$(i%)
LOOP
CLOSE #1
Which displays
"Ronaldo","10"
"David","4"
"Doanald","3"
"Schnider","2"
I want to merge above two files and get the result as
"David","UK","4"
"Doanald","SA","3"
"Mardona","Argentina",""
"Pele","Brazil",""
"Ronaldo","Brazil","10"
"Schnider","Germany","2"
Pl Help
Regards
Samyo
Last edited by si_the_geek; Jun 17th, 2006 at 08:04 AM.
Reason: added vbcode tags for readability
-
Jun 17th, 2006, 08:10 AM
#2
Re: sorting and merging of 2 sequnetial files
Is this VB? If so, I'll move this to the classic VB forum (which will get more people looking at it).
In order to merge the files you will need to read in the data from both files, but have it "lined up", so that the Goals$ array has the same order as the Names$ and add$ arrays.
I would recommend changing the second part of the code to not read directly into the arrays - but instead use variables which you can use to compare against the values in the Names$ array (using a For/Next loop) to find the right row, or (if not found) add a new row to the array. You would then put the goal data into the same position in the goals$ array.
When the data is in the arrays, you can simply write it out to a file.
-
Jun 17th, 2006, 08:40 PM
#3
Thread Starter
Member
Re: sorting and merging of 2 sequnetial files
Already i've put in classic VBforums
classic -----http://www.vbforums.com/showthread.php?t=411429
still i've not got satisfied reply
i dont want to use split function
if you can help without using split fucntion it would be great
Thanks
Regards
Samyo
-
Jun 18th, 2006, 05:00 AM
#4
Re: sorting and merging of 2 sequnetial files
As this is VB it belongs in a VB forum, not here.
As you already have another thread there, I will close this one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|