Re: dbf 2 EDS database

new topic     » goto parent     » topic index » view thread      » older message » newer message

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C1EB10.4E22EB80
	charset="iso-8859-1"

Hello Vlado,

I know of no such utility that produces a global conversion but I have attached
a parser that I used to in conjunction with Daniel Berstein's dbfeng util.
This might give you an idea how you could write your own routine.
I wrote this many moons ago to convert some Family tree data from DBIII
to an EDB file.

Hope it helps!

Euman
euman at bellsouth.net

...if the US Government were ever to get really serious about Internet 
security, the top players in Microsoft's management hierarchy would find 
themselves handcuffed, blindfolded, led onto a tarmac within some obscure 
Air Force base, and shot.
-- Thomas C Greene (http://www.theregister.co.uk/content/55/23223.html)
Bombs burst in air and the rocket red glare.......
Hope this keeps the pricks in charge of spying on the common man a bit of extra
work.

----- Original Message ----- 
From: "Vlado" <vkusnirak at usske.sk>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, April 23, 2002 10:46 AM
Subject: dbf 2 EDS database



Hello,

I'm looking for some convertor form DBASE *.dbf database to
the EDS database or I need some routines for accessing 
.DBF files. I tried use an routines from Daniel Berstein, but
I can't read all fields database.

Vlado Kusnirak





------=_NextPart_000_0007_01C1EB10.4E22EB80
Content-Type: application/octet-stream;
	name="parser2.ex"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="parser2.ex"

with type_check
with trace

include dbf_eng.e
include database.e

--trace(1)
global function Strip(sequence s,sequence delimeters,integer mode)
--Quark: Strip whitespace from s in mode way (0=left,1=right,2=both)
if equal(mode,0) or equal(mode,2)then
   while length(s) and find(s[1],delimeters) do
      if equal(length(s),1) then
  s={}
      else
  s=s[2..length(s)]
      end if
   end while
end if
if equal(mode,1) or equal(mode,2) then
   while length(s) and find(s[length(s)],delimeters) do
      if equal(length(s),1) then
  s={}
      else
  s=s[1..length(s)-1]
      end if
   end while
end if
return s
end function

sequence shortform, longform

shortform = {"Albright","Bell","Benton","Childres","Currie","Harr","Heaf",
             "Hicks","Over","Rayl","Russ","Simp","Winfree","Zimmer"}
             
longform = {"Albright","Bell","Benton","Childres","Currie","Harrison","Heafner",
            "Hicks","Overman","Ray","Russell","Simpson","Winfree","Zimmerman"}


puts(1, "Creating Family Database\n")

if db_create("family", DB_LOCK_NO) != DB_OK then
db_close() 

    puts(2, "Couldn't create the database!\n")
    abort(1)
end if
puts(1, "Done!\n")

object s1, s2, desc, data, seq

function inddesc( sequence s3)

data = repeat(0, 22)

        data[1] = Strip(s3[2],{32},2) 
        data[2] = Strip(s3[3],{32},2) 
        data[3] = Strip(s3[4],{32},2) 
        data[4] = Strip(s3[5],{32},2) 
   	data[5] = Strip(s3[6],{32},2) 
   	data[6] = Strip(s3[7],{32},0) --v
   	data[7] = Strip(s3[8],{32},0) --v      
   	data[8] = Strip(s3[9],{32},0) --v            
   	data[9] = Strip(s3[10],{32},0) --bday  --v          
        data[10] = Strip(s3[11],{32},2)
   	data[11] = Strip(s3[12],{32},0) --date married --v                   
   	data[12] = Strip(s3[13],{32},2) -- place married
        data[13] = Strip(s3[19],{32},2)
   	data[14] = Strip(s3[20],{32},2)
   	data[15] = Strip(s3[21],{32},2) 
   	data[16] = Strip(s3[22],{32},2) 
   	data[17] = Strip(s3[23],{32},2) 
   	data[18] = Strip(s3[14],{32},0) -- death date --v
   	data[19] = Strip(s3[15],{32},2) -- place died
   	data[20] = Strip(s3[16],{32},0) -- bury date --v
   	data[21] = Strip(s3[17],{32},2) 
   	data[22] = Strip(s3[18],{32},2)

    return data
    
end function

integer mis, len

for index = 1 to length(shortform ) do
	
   s1 = dbf_open(shortform[index] & ".dbf")  
   s2 = dbf_readall(s1)

   if not integer(s2) then

     dbf_close(s1)

     puts(1, "Creating Table  " & longform[index] & "\n")
     
     if db_create_table(longform[index]) != DB_OK then
        puts(2, "Couldn't create table!\n")
     end if

     puts(1, "Inserting Records into  " & longform[index] & "\n\n")
     
     len = length(s2)
     
     if len = 0 then
     else     
     seq = value(Strip(s2[len][1],{32},0)) -- account for extra sequences 
     
     seq = repeat({}, seq[2])
     
     for x = 1 to length(s2) do
     	
         desc   = value(Strip(s2[x][1],{32},0)) 
                 	     	
     	 seq[desc[2]] = s2[x]
     	 
     end for
                
        mis = 1
        
        for i = 1 to length(seq) do
        	
            if length(seq[i]) > 0 then
        	           
            desc   = value(Strip(seq[i][1],{32},0)) 
            
            if equal(desc[2], i) then                   
               data = inddesc(seq[i])
               
               
               if db_insert(i, data) != DB_OK then
                  puts(2, "insert failed!\n")
               end if
               
            else
        	
               mis =  i + 1
               
               data = inddesc(seq[mis])

               if db_insert(mis, data) != DB_OK then
                  puts(2, "insert failed!\n")
               end if
                            
            end if
            
            else
            	
               if db_insert(i, {"No Data"}) != DB_OK then
                  puts(2, "insert failed!\n")
               end if
            	
            
            end if            

        end for
        
        seq = {}
        s2  = {}
        
        end if
   end if                     
end for

     if db_create_table("Deleted") != DB_OK then
        puts(2, "Couldn't create table!\n")
     end if


db_close() 

puts(1, "Finished Consolidating\n\n")
puts(1, "Press any key\n")

if getc(0) then
end if


------=_NextPart_000_0007_01C1EB10.4E22EB80--

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu