Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting data from Btrieve dta files (DOS)

Status
Not open for further replies.

AMOSMP

IS-IT--Management
May 12, 2004
4
0
0
GB
Hi,

I am looking to extract data from Btrieve dta files (running in DOS) ideally into Access or Excel. I realise that we can't link directly using ODBC as this version doesn't seem to support this?

Is there any way to directly dump out the data from these files in a usable format (csv, txt etc)??

Any help would be appreciated.

Thanks in advance

T %-)
 
There's no easy way to do this. Btrieve does not store field information so the best you can do with Btrieve utilities would be a byte image of the record. Might work if most of the fields are strings but numeric data types will be binary.
If you know the record structure, you might look into third party tools to create DDFs and then use a newer version of Btrieve/Pervasive to export the data.
You could also write a program to read the data files and write them out to whatever format you want.

info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
Mirtheil,

Thanks for your info, it is what i was expecting.

We have an export system that does export the data, but it is in a 'list' format. It may be easier to write something to adapt this structure to what i require.

Tony
 
If you need to create your DDF files you an try BtSearch at It allows you to analyze the structure and build the DDF files. Once built it will export to dbase or ascii formats.


Gil
 
I have been doing this sort of extraction myself, with a legacy Btrieve system (6.1.5), flattening the files and normalizing them for insertion into Oracle tables through sql loader.

The flattening process is somewhat tricky, but you can get around it if you're willing to jump through a few hoops.

I wrote a BAT file that does the following (I've removed the pathing for simplicity):

BTRIEVE
BUTIL -RECOVER CCXYZ.DAT CCXYZ.TXT
BUTIL -STOP

This flattens the Btrieve file CCXYZ.DAT into CCXYZ.TXT.

CCXYZ.TXT contains two comma-separated fields:
record length
record content

Trivially, I used -RECOVER rather than -SAVE because I didn't want to jack with key issues. (I can get lazy sometimes!)

I wrote a VBscript that calls the BAT file, then normalizes the variable-length records to fixed-length by stripping the length field and comma, padding the record to the maximum length (using zeroes rather than spaces, if my table columns contain numeric definitions), and then loading the resulting files into Oracle with the sql load utility. If you have any binary/packed numeric data fields, your VBScript might want to comprehend those and turn them into something that won't choke Excel. Keep this in mind, however. The binary value might get read as something that chokes the normal sequential file "Line Input" command, and you may be forced to open the file as binary. Not that this is a problem, but just be prepared for it.

The upside of jumping through all these hoops is that you can also normalize -- or delimit -- your fields for smooth loading into yor spreadsheet. Once you have flattened the file, you can manipulate it as you need.

Three caveats about BTRIEVE and BUTIL:
1. The 1997 version of BTRIEVE works better than the 1992.
2. BUTIL is not very friendly with some files, and I'm currently researching a problem I have trying to flatten a 109-mb Btrieve file.
3. You MUST use the old 8.3 file naming convention, at least with the version of BUTIL that I have. Your BUTIL output file will cause a funky error message if you make it longer than 8 characters or if you use more than 3 characters in your extension name.

Any of you Tek-Tips experts might tell me where I'm all wet on this, since I have had to make all this up as I go along.

If there's a straightforward routine out there that makes flat files, I would be more than happy to consider an immediate purchase.

For you, AMOSMP, I hope this helps.










 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top