Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Jun 18, 2018 1:54 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: working with old Dbase (.dbf) files
PostPosted: Sat Jan 26, 2013 3:41 am 
Offline
User avatar

Joined: Sat May 28, 2011 11:28 pm
Posts: 130
Location: Beijing China
Hi,

I need to make a small tool to e-mail invoices as pdf files,
the problem is that the old software is very old DOS software about 20 years old
now I want to be able to read those DBF files to get all the data for the invoices

does anyone have a sugestion on how to do that?

Thanks

_________________
For great Music got to my podcast Website!!!
http://podcast.1945mf-china.com


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Sat Jan 26, 2013 4:22 am 
Offline

Joined: Tue Nov 13, 2007 11:48 am
Posts: 189
Location: Belgium
I know the "old" filemaker could read and import dbf records.
Since it's been ages since i used filemaker, i don't know if they still support that... :?

I found some conversion-snippets and apps on google :roll: for import from dbf to mysql or import to postgresql...

http://www.convert-in.com/dbf2sql.htm
http://www.linkedin.com/answers/technology/information-technology/databases/TCH_ITS_DBS/669522-67828758
http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL

You'll have to pick a new database type (mysql/postgres/...) and port those dbf-files to the new format :)


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Sat Jan 26, 2013 9:39 am 
Offline

Joined: Tue Nov 13, 2007 11:48 am
Posts: 189
Location: Belgium
I just noticed that if you use Navicat, you can import from .dbf using a GUI, with the option to create the tables from scratch.

I think you have a navicat demo period of 30days, that should be enough to get you started...


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Sat Jan 26, 2013 11:23 am 
Offline
User avatar

Joined: Sat May 28, 2011 11:28 pm
Posts: 130
Location: Beijing China
If I needed to load to dbf files once, then I could easly do it with Excel, but I need the app that I'm going to write to be able to read to dbf files.
no need to write just read.

_________________
For great Music got to my podcast Website!!!
http://podcast.1945mf-china.com


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Wed Jan 30, 2013 8:26 am 
Offline

Joined: Thu Nov 10, 2005 4:07 am
Posts: 681
Location: Ely, England
Microsoft provide an ODBC driver for dBase files.


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Wed Jan 30, 2013 9:55 am 
Offline
User avatar

Joined: Fri Jul 09, 2010 7:16 am
Posts: 103
Location: Den Haag, Netherlands
This could be the perfect moment to convert the 20 year old DBF-database (dBase) to a modern database. :wink:

_________________
MacBook Pro (late 2008), OSX Mountain Lion 10.8.2, Real Studio 2012r2


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Sat Feb 02, 2013 3:15 am 
Offline

Joined: Wed Jan 19, 2011 2:52 am
Posts: 11
It is not so strange to still use dbf files, as they are one of the fundamental components of the shape file format used by geographic information systems (GIS) such as ArcView or QuantumGIS. I tried (unsuccessfully) to manage dbf files using Real Studio with ODBC and if someone had succeeded I would like to know how to do. :)

bye

Sergio


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Sat Feb 02, 2013 4:25 am 
Offline

Joined: Wed Mar 17, 2010 10:33 am
Posts: 258
Location: Sydney, Australia
SteveW wrote:
Microsoft provide an ODBC driver for dBase files.

and if you have trouble with this driver get the
'Visual FoxPro OLE DB Provider (VfpOleDB.dll)' from microsoft.


Regards
Denis


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Tue Mar 05, 2013 7:49 pm 
Offline
User avatar

Joined: Sat May 28, 2011 11:28 pm
Posts: 130
Location: Beijing China
doing this in windows wouldn't be so hard, but those Microsoft drivers will not work on Mac osx

_________________
For great Music got to my podcast Website!!!
http://podcast.1945mf-china.com


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Thu Mar 07, 2013 1:37 am 
Offline

Joined: Tue Oct 06, 2009 2:38 am
Posts: 435
Why not just read the DBF file directly?

http://www.dbf2002.com/dbf-file-format.html


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Thu Mar 07, 2013 6:13 am 
Offline

Joined: Mon Nov 21, 2011 11:46 am
Posts: 7
You could also try use ruby for this task.
May this gem helps: https://rubygems.org/gems/dbf
Here a direct link to the documentation: http://rubydoc.info/github/infused/dbf/frames
I like ruby for database that much, with activerecord & co its a pleasure to code converters and similar software.


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Sun Mar 10, 2013 7:54 am 
Offline
User avatar

Joined: Sat May 28, 2011 11:28 pm
Posts: 130
Location: Beijing China
brisance wrote:
Why not just read the DBF file directly?

http://www.dbf2002.com/dbf-file-format.html


Yes I wrote a class the read the DBF as a binary stream.
I still have a problem with speed

I need to reed information from 4 tables
3 of them is not a very big deal, but one as like 400.000 records

at this moment I load all the files in a multidemional array

like if the table as 6 fields, and 5 records, then i redim an array to Redim Record(4,5)
this works great.

but loading 400.000 records in a array take a long time

see my code

Getting a record as a string value

progress.Value = 0
progress.Maximum = TRecords * 2
progress.Refresh
dim F as FolderItem
dim x as integer
Dim DataStream as BinaryStream
f = new FolderItem (mDBF_PATH + "/" + Tables(mSelectedTabel), folderitem.PathTypeShell)
if f.Exists then
Datastream = DataStream.Open (f, false)
DataStream.LittleEndian = True
DataStream.Position = HeaderSize + 1
//Read All Records In MEM
ReDim UCRecords(-1)
if TRecords > 0 then
for x = 1 to TRecords
UCRecords.Append datastream.Read(DataRecordSize)

if x mod 500 = 0 then
progress.Value = x
progress.Refresh
end if
next x
'msgbox cstr(UCRecords.Ubound + 1) + " - " + UCRecords(UCRecords.Ubound)
end if


Splitting the data in an array as Variant

ReDim TempData(TRecords - 1, FieldsFromOpenDBF.Ubound)
dim y, c as integer
for x=0 to UCRecords.Ubound
c=1
for y=0 to FieldsFromOpenDBF.Ubound
TempData(x,y) = ReplaceAll(mid(UCRecords(x),c,FieldsFromOpenDBF(y).FSize)," ","")
c=c + FieldsFromOpenDBF(y).FSize
next y

if x mod 1000 = 0 then
progress.Value = TRecords + x
progress.Refresh
end if
next x

if i could improve the second part of the code, would be awesome
because the table with 400.000 records with like 12 fields or so takes a long time
it loops 12 x 400.000 times

the second problem is, how can I search a value in a multidimensional array?
say I want to look a value in a field.
now I loop through the full array and this takes too much time

3rd problem but easy to solve but I worry about the spead
I'm cutting all spaces by replacing " " with ""
no problem with integer double or date values, but text values has some spaces that shouldn't be cutted.
is there an easy ans fast way to cut all the spaces in front and after the text?

see code
dim test as string = "    This is a Test     "
// space cutting code

msgbox test // results "This is a Test"


any suggestions?

Cheers

_________________
For great Music got to my podcast Website!!!
http://podcast.1945mf-china.com


Top
 Profile  
Reply with quote  
 Post subject: Re: working with old Dbase (.dbf) files
PostPosted: Sun Mar 10, 2013 8:25 pm 
Offline

Joined: Tue Oct 06, 2009 2:38 am
Posts: 435
Some thoughts:

1. You can use the Trim() function to remove leading and trailing whitespace. http://docs.realsoftware.com/index.php/Trim
2. Although ODBC is supposed to solve a problem like this, it has its own problems (e.g. finding the appropriate ODBC driver with the right version, installing it etc). Based on what you've revealed so far, it just might be a better idea to read the data and create a SQLite database. In this way you can execute SQL statements/queries against it, rather than trying to reinvent the wheel (yet again).


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group