Reading DBASE files 
Author Message
 Reading DBASE files

Hello !

Could someone help me get started
doing I/O  to DBASEIII, or DBASE IV
type of data files (.DBF files) ? I have
some ideas but not really sure what is
the best way to approach this problem.

I looked at the data files and the records are
seperated by a  * (ascii character 42) .

Can  I use STRING or UNSTRING to convert
the data to something that is easier for
me to work with?  I thought about just
using something like:

01 INPUT-BUFFER      PIC X(234)
01 OUTPUT-BUFFER     PIC x(234)

then code like:

STRING INPUT-BUFFER DELIMITED BY "*"
       INTO OUTPUT-BUFFER.

and then writing a new file to read,
that would be easier to work with.

If I could read the record from the " * "
character, it would be no problem setting up
the picture clauses with the information below,
and I could then manipulate it. However, I am
not sure how to start reading each record at
the "*" rather than the next line.

The file structure of the data files:

   Fld #        Field Name     Width
   1            FIRST          12
   2            LAST           18
   3            TITLE          30
   4            COMPANY        30
   5            STREET         30
   6            CITY           20
   7            STATE          2
   8            ZIP            10
   9            AC1            3
   10           PH1            8
   11           EXT1           4
   12           AC2            3
   13           PH2            8
   14           EXT2           4
   15           COMMENT        50
   16           TAG            1

   Total Number              234

Once again, thanks in advance, any information that
you care to offer will be sincerely appreciated.

Greetings,
   joe
--- timEd/2 1.10
 * Origin:   0   (0:0/0)



Tue, 18 May 1999 03:00:00 GMT  
 Reading DBASE files

Quote:

> Hello !

> Could someone help me get started
> doing I/O  to DBASEIII, or DBASE IV
> type of data files (.DBF files) ? I have
> some ideas but not really sure what is
> the best way to approach this problem.

> [...]

You might want to check

 ftp://ftp.borland.com/pub/techinfo/techdocs/database/dbase/dos

for some file formats.  They're C structs, but they may help.



Wed, 19 May 1999 03:00:00 GMT  
 Reading DBASE files

Quote:

> Hello !

> Could someone help me get started
> doing I/O  to DBASEIII, or DBASE IV
> type of data files (.DBF files) ? I have
> some ideas but not really sure what is
> the best way to approach this problem.

> I looked at the data files and the records are
> seperated by a  * (ascii character 42) .

> Can  I use STRING or UNSTRING to convert
> the data to something that is easier for
> me to work with?  I thought about just
> using something like:

> 01 INPUT-BUFFER      PIC X(234)
> 01 OUTPUT-BUFFER     PIC x(234)

> then code like:

> STRING INPUT-BUFFER DELIMITED BY "*"
>        INTO OUTPUT-BUFFER.

> and then writing a new file to read,
> that would be easier to work with.

> If I could read the record from the " * "
> character, it would be no problem setting up
> the picture clauses with the information below,
> and I could then manipulate it. However, I am
> not sure how to start reading each record at
> the "*" rather than the next line.

> The file structure of the data files:

>    Fld #        Field Name     Width
>    1            FIRST          12
>    2            LAST           18
>    3            TITLE          30
>    4            COMPANY        30
>    5            STREET         30
>    6            CITY           20
>    7            STATE          2
>    8            ZIP            10
>    9            AC1            3
>    10           PH1            8
>    11           EXT1           4
>    12           AC2            3
>    13           PH2            8
>    14           EXT2           4
>    15           COMMENT        50
>    16           TAG            1

>    Total Number              234

> Once again, thanks in advance, any information that
> you care to offer will be sincerely appreciated.

> Greetings,
>    joe
> --- timEd/2 1.10
>  * Origin:   0   (0:0/0)

Hi !

Here you have some notes about .DBF

'*' is not record delimiter. It is mark for deleted records.
        - * record deleted
        - <SPACE> not deleted

Here you have part of my DBASE emulator program. For how to using NTX
files, you should send me E-Mail.

Uses
   Dos, Crt ;

Var
   F        : File ;
   FCount   : Integer ;
   StartRec : Integer ;
   I        : Integer ;
   J        : Integer ;
   TempStru : Record
                 FieldName : Array[0..10] Of Char ;
                 FieldType : Char ;
                 Null1     : Array[12..15] Of Char ;
                 FieldLen  : Byte;
                 FieldDec  : Byte;
                 Null3     : Array[18..31] Of Char ;
              End;
   FieldName : String ;

Function GetType( C : Char ) : String ;
Begin
   Case C of
      'C' : GetType := 'Char   ' ;
      'N' : GetType := 'Numeric' ;
      'L' : GetType := 'Logical' ;
      'D' : GetType := 'Date   ' ;
      'M' : GetType := 'Memo   ' ;
      else
            GetType := 'Unknown' ;
   End;
End ;

Begin
   FileMode := $42 ;          (* Provide NETWORK access *)
   If ParamCount = 0 Then Halt(1) ;
   Writeln('Structure of ' + ParamStr(1));
   Assign( F, FileName ) ;
   {$I-}
   Reset( F, 1 ) ;
   {$I+}
   If IOResult <> 0 Then
   Begin
     Writeln('Error opening file ' + ParamStr(1));
     Halt(2);
   End ;
   Seek( F, 8 ) ;
   BlockRead( F, StartRec, 2, I ) ;             (* Read first data
position *)

   Seek( F, 32);
   FCount := ( StartRec + 1) div 32 - 1 ;       (* Get number of FIELDS
*)
                                                (* Each field
description is 32 bytes in length *)
   For I := 1 To FCount do
   Begin
      BlockRead( F, TempStru, SizeOf( TempStru ), StartRec ) ;
      J := 0 ;

      FieldName := '' ;    
      While ( TempStru.FieldName[ J ] <> #0 ) and ( J < 10 ) do    (*
Field name is 10 bytes long or

delimited by <NULL> *)
      Begin
         FieldName := FieldName + TempStru.Fieldname[ J ] ;
         Inc( J ) ;
      End ;

      Writeln( 'Field name :' + TempStru.FieldName  );
      Writeln( 'Field type :' + GetType( TempStru.FieldType ));
      Writeln( 'Field len  :', TempStru.FieldLen);
      Writeln( 'Field dec  :', TempStru.FieldDec);
      Writeln ;
   End;
   Close( F ) ;
End.
=================================================================================================
Ales Romaniuk
Ljubljana,
Slovenia



Thu, 27 May 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. APL reading dBase files

2. Reading Dbase files

3. Unable to read dbf file as dbase file

4. Read from a dBase.IV file

5. Reading text file into DBase?

6. dbase-file/clipper-index read-module

7. TCL proc for reading/writing Xbase (dBase) files?

8. Converting dBase III to dBase IV files ?

9. convert DAT-files to DBase-files

10. Need old file-dbase 1.0 help file?

11. need to convert a DAT file on cobol a DBF file on dbase

12. To everyone : Visual dbase 7.5 or dBase 2000 SHIT OR OK

 

 
Powered by phpBB® Forum Software