Database import

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
RDalzell
Posts: 205
Joined: Thu Jan 28, 2010 6:57 am
Location: Alsip, Illinois USA

Database import

#1 Post by RDalzell »

Hi everybody,

I am unable to import the Test.Txt file into the Test.Dbf

I would prefer to have this as a menu option rather than an external program.

Using xdot, i get 4 empty records appended.

Any help would be appreciated.

Thanks,
Rick
Attachments
Test.zip
(1.29 KiB) Downloaded 875 times

wkedv
Posts: 12
Joined: Mon Feb 08, 2010 3:04 am

Re: Database import

#2 Post by wkedv »

Hi,

The separator between the fields " ~ " is the problem.

This is not a delimiter.

Kurt

User avatar
RDalzell
Posts: 205
Joined: Thu Jan 28, 2010 6:57 am
Location: Alsip, Illinois USA

Re: Database import

#3 Post by RDalzell »

Hi Kurt,

I tried the parameter DELIMITED WITH to no avail.

When using xdot, the fields map properly as long as the delimiter is changed from the defaulted comma to the tilde.

Rick

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Database import

#4 Post by rdonnay »

Rick -

I'll give it a look and get back to you.

Meanwhile, take a look at \exp19\samples\csv\csvimp.prg.
There is a new one attached. I made some changes recently for Aidan Harland.

I use this utility for importing to a DBF from a CSV file.
It allows for mapping of fields.

BTW - I will be in Glen Ellyn Tuesday thru Friday this week. Flying back home on Saturday.
It would be great if we can find time to get together for dinner one night.

Roger
Attachments
csvimp.zip
(6.12 KiB) Downloaded 856 times
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Database import

#5 Post by rdonnay »

Here's program that will do the import:

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

Import( 'Test', 'Test.Txt', '~' )

RETURN nil

* --------------

FUNCTION Import( cDbf, cText, cDelim )

LOCAL nHandle, cLine, aFields, aStru

USE (cDbf)
aStru := (cDbf)->(dbStruct())
nHandle := DC_TxtOpen(cText)

DO WHILE !DC_TxtEof(nHandle)

  cLine := DC_TxtLine( nHandle )
  aFields := DC_TokenArray(cLine,cDelim)
  FormatFields(aFields,aStru)
  IF (cDbf)->(DC_AddRec(5))
    (cDbf)->(Gather(aFields))
    (cDbf)->(dbRUnlock())
  ENDIF
  DC_TxtSkip(nHandle,1)

ENDDO

(cDbf)->(dbCloseArea())
DC_TxtClose(nHandle)

RETURN nil

* ---------

PROC appsys ; return

* ---------

FUNCTION FormatFields( aFields, aStru )

LOCAL i, cType

FOR i := 1 TO Len(aStru)
  cType := aStru[i,2]
  IF cType = 'D'
    aFields[i] := CtoD(aFields[i])
  ELSEIF cType = 'L'
    aFields[i] := Upper(aFields[i])[1] $ 'YT'
  ELSEIF cType = 'N'
    aFields[i] := Val(aFields[i])
  ENDIF
NEXT

RETURN nil
The eXpress train is coming - and it has more cars.

User avatar
RDalzell
Posts: 205
Joined: Thu Jan 28, 2010 6:57 am
Location: Alsip, Illinois USA

Re: Database import

#6 Post by RDalzell »

Thanks Roger,

Next week sounds great, let me know when is best for you, Ruths Chris, Harry Caray's, 94th Aero Squadron and Maggianos are nearby should you have a hankering for some red meat in your diet....

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Database import

#7 Post by rdonnay »

Not NEXT week, THIS week! Leaving tomorrow!!!
The eXpress train is coming - and it has more cars.

User avatar
RDalzell
Posts: 205
Joined: Thu Jan 28, 2010 6:57 am
Location: Alsip, Illinois USA

Re: Database import

#8 Post by RDalzell »

OK, gee you must be HUNGRY.....

Have a meeting tomorrow evening will leave the remainder of the week for when you are available.

See you soon.

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Database import

#9 Post by rdonnay »

Spending the week with lawyers. Gonna learn a lot about depositions.

I'll call you after I find out what the lawyers have in mind first.
The eXpress train is coming - and it has more cars.

Post Reply