RE: Extracting data directly from dbf files...

2004-04-08 Thread Jacques G.
>From: Lee Messenger 
>Has anyone developed any processes to natively >read
'.dbf' type files
>from within Universe basic?

I wrote one for Universe back in 1995 and improved on
it up until 1998.  It converts dbf files, creates an
include file which has a DIM and equates for a matrice
to use the fields with their names.  It also creates
dictionnary elements for the converted file using the
dbf headers.It does not convert .dbt files.   I
based it on a dbf file format description I found on
the Internet back then.

I also made it able to convert fixed-length files,
delimited files provided a header is defined for the
file.

The program asks several questions the first time it
converts a file.  It will remember the answers for
subsequent conversions.

It was tested over several data conversions I did
overseas.  The reason I had the tool produce an
include file with equates is that sometimes the
customers would provide me with .dbf files for the
live conversion in which some fields were sometimes in
different positions from the test data files I was
given to develop the conversion programs.  The equates
includes made it possible for me to manipulate the
fields by their names (all I had to do is recompile
the program which used the includes).

The program also generates a tab-delimited excel file
with the name of each column on each line with a
description of the data type.  This was initially for
me to document what the fields were for.  



__
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/
-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


RE: Extracting data directly from dbf files...

2004-04-08 Thread Scott Ballinger
I think I got this stuff from wotsit.org... The header & record size are
stored as binary fields in pos 9-10 & 11-12 of the file header. Here is
some D3 code that I use to read dbf files: (you still need to already
know the record layout re: fields, etc, although I'm sure that
information is encoded in the header as well; this code just figures out
where the header ends so you can start parsing the data.)

--- begin basic---
*  [42] Sometimes headers are one char smaller than expected,
* which shifts entire file.  To watch for this, check
* the first record's RC code -- if that doesn't start
* with an "R", then we're shifted, so subtract one
* from the header size.

block.size = 1
execute "cd /path/to/files"
execute "!exec ls *dbf" capturing dbf.files

max = dcount(dbf.files,@am)
for n = 1 to max
  dbf.file = dbf.files
  print
  print "now processing ":dbf.file:"..."
  fv = %open(dbf.file,o$rdonly)
  char new.block[block.size]

  first.time = 1
  done = 0
  loop until done do

r = %read(fv,new.block,block.size)

if r lt block.size then
  done = 1
  new.block = new.block[1,r]
end

if first.time then
  * header.size & rec.size can be determined by reading the
  *  header data, but make sure that block size is greater
  *  than the header size.
  h1 = seq(new.block[9,1])
  h2 = seq(new.block[10,1])
  header.size = (256*h2)+h1 + 2
  r1 = seq(new.block[11,1])
  r2 = seq(new.block[12,1])
  rec.size = (256*r2)+r1

  ** [42]
  rc.index = header.size + 100
  rc.char  = new.block[rc.index,1]
  if rc.char ne "R" then
header.size = header.size - 1
  end

  first.time = 0
  block = new.block[header.size,99]
end else
  block = block:new.block
end

loop
while len(block) ge rec.size do
  rec = block[1,rec.size]
  block = block[rec.size+1,99]
  gosub 1000  ;* parse the rec
repeat

  repeat

  * last one may be partial record
  ach.rec = block
  gosub 1000

  x = %close(fv)

next n
-- end basic -

I have also seen a freeware DOS program that convert dbase files to csv
(google for convert file?), but you have to have a DOS environment
available to shell out to...

Good Luck,

Scott Ballinger
Pareto Corporation
Edmonds WA USA
425-670-0831

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Richard A. Wilson
Sent: Wednesday, April 07, 2004 3:35 PM
To: U2 Users Discussion List
Subject: Re: Extracting data directly from dbf files...


I'm fairly certain that the cedarville download utility handles dbf 
files. Since it comes with source code perhaps you can change the write 
logic to read

Rich

Lee Messenger wrote:

> Has anyone developed any processes to natively read '.dbf' type files 
> from within Universe basic?
> 
> I know we could use ODBC or UniObjects but prefer a more direct 
> approach.
--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


Re: Extracting data directly from dbf files...

2004-04-08 Thread Don Verhagen
I have a program(s) to convert a DBF to a U2 file natively it's in Unidata not 
Universe though.

Email me directly if interested.

Thanks,


>>> [EMAIL PROTECTED] 4:47:06 PM 04/07/2004 >>>
Has anyone developed any processes to natively read '.dbf' type files from
within Universe basic?

I know we could use ODBC or UniObjects but prefer a more direct approach.


Lee J Messenger
Sr VP Operations
[EMAIL PROTECTED] 

DLT Transportation Services, Inc.
Phone :(816) 242-4505
Fax   :(816) 483-7222


-- 
u2-users mailing list
[EMAIL PROTECTED] 
http://www.oliver.com/mailman/listinfo/u2-users

--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


Re: Extracting data directly from dbf files...

2004-04-07 Thread Richard A. Wilson
I'm fairly certain that the cedarville download utility handles dbf 
files. Since it comes with source code perhaps you can change the write 
logic to read

Rich

Lee Messenger wrote:

Has anyone developed any processes to natively read '.dbf' type files from
within Universe basic?
I know we could use ODBC or UniObjects but prefer a more direct approach.

Lee J Messenger
Sr VP Operations
[EMAIL PROTECTED]
DLT Transportation Services, Inc.
Phone :(816) 242-4505
Fax   :(816) 483-7222

--
Richard A. Wilson
Lakeside Systems
Smithfield, RI, USA
Voice 401-231-3959
Fax   401-231-3943
[EMAIL PROTECTED]
www.lakeside-systems.com
--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


Extracting data directly from dbf files...

2004-04-07 Thread Lee Messenger
Has anyone developed any processes to natively read '.dbf' type files from
within Universe basic?

I know we could use ODBC or UniObjects but prefer a more direct approach.


Lee J Messenger
Sr VP Operations
[EMAIL PROTECTED]

DLT Transportation Services, Inc.
Phone :(816) 242-4505
Fax   :(816) 483-7222


-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users