Normal Topic Merge Records (Read 625 times)
North_Guy
Member
*
Offline


No personal text, yet.

Posts: 25
Location: Alberta, Canada
Joined: Sep 7th, 2005
Merge Records
Oct 7th, 2005 at 10:33pm
Print Post Print Post  
Just thought I would throw this question out there in the off chance that someone may have done this. I have exported a Sesame database to a comma seperated .txt file. There are ~6000 unique records and the .txt file contains ~52000 records in total, with each record having about 8 copies in the .txt file. They aren't exact copies however, some fields are different and I need to merge all 8 copies into one copy with the different fields being seperated by a special char. such as a semi-colon.  Any suggestions? I have written some code but I get all the duplicate records in the out put double element array, I think I need a function that will allow me to delete an array index but can't find any such function in the Sesame programming documentation. In the code below, a[m,4]  contains a unique value for the ~6000 records.
Thanks

while m < numOfRec {
     l = l+1
     if a[m,4] = a[l,4] Then {
                 For n = 1 to 46
                 if a[m,n] <> a[l,n]{
                           b[m,n] = a[m,n] +";"+ a[l,n]
                       
                 }
             next                  
           
     }
     
     if l = numOfRec {
           m = m+1
           l = m
     }
}
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Merge Records
Reply #1 - Oct 8th, 2005 at 10:43am
Print Post Print Post  
From your description, it sounds like you have a hierarchial ascii export from Sesame or Access or whatever, where each child record repeats the parent information to keep track of which child goes with each parent, correct?

If so, it may be easiest to approach this from the other direction. Instead of trying to read in the file which is necessarily complex, could you instead, export from the application using the built in programming language, so that a parent and all of its children are all on the same line in the export file?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
North_Guy
Member
*
Offline


No personal text, yet.

Posts: 25
Location: Alberta, Canada
Joined: Sep 7th, 2005
Re: Merge Records
Reply #2 - Oct 12th, 2005 at 2:35pm
Print Post Print Post  
From your description, it sounds like you have a hierarchial ascii export from Sesame or Access or whatever, where each child record repeats the parent information to keep track of which child goes with each parent, correct?


Yes, I have exported an ascii file from Sesame's export spec and each record has at least 8 rows in the file, with usually only one or two rows having different data in its fields.

If so, it may be easiest to approach this from the other direction. Instead of trying to read in the file which is necessarily complex, could you instead, export from the application using the built in programming language, so that a parent and all of its children are all on the same line in the export file?

Unfortunatley I can't export using the built in programming language, scope seems to be the problem, I struggled with that issue for a while. The only function that I could find that would allow me to traverse through the records one at a time using an index was @FormFieldValue() but its scope is limited to the open form and I have several subforms in my application that contains the data I need. If you know of another way please let me know. Thanks for your help.

  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Merge Records
Reply #3 - Oct 12th, 2005 at 3:35pm
Print Post Print Post  
NorthGuy,

@FormFieldValue is designed to traverse subforms. If you were able to do the hierarchical export of your data, then all the child data is available on the open form.

The problem is this:
If you combine all the child record data onto the same line as the parent record, the result will be a file where each line ("record") has a different number of values ("fields"). This is a big no-no to any program (such as Word) where you might then attempt to import or merge with the file you create.

That is why the file is produced in the format it is. Access, mySQL, etc. will produce the same result if your flatten parent/child data into a single export file.

Can you explain how this export file will be used and why you need to concatenate, rather than flatten the data? It might help us to suggest a solution. I can show you how to traverse the child records and write out the data, but I think the resulting file may cause you trouble farther down the road.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged