|
Home > Archive > Getting Started with dBASE > January 2006 > APPENDING
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| JOHN PHILLIPS 2006-01-06, 3:23 am |
| Can't append a .txt file that is tab seperated
any suggestions
| |
| John Marshall 2006-01-06, 11:23 am |
|
John:
There are a number of known issues (in 2.5) that rendered Append From /Copy To unusable. I do not know if these have been resolved in 2.6. I have issue when using the clause Delimited With Blank. I finally had to write my own routine to solve this
. I was discouraged that these functions didn't work, but happy with the control once I made the switch.
Here is a sample of code that replaced the end of line characters with a different set for Excel compatability. I hope it helps, otherwise give some examples.
function fixfile()
local fid,dest
f = new File( )
g = new file()
// Create File object
// ** File Declaration Section **
// ** Native eSysco source file
fid = " F:\epurchasing\bids\
sysco\syscodnloadexp
ort.csv"
// ** temp fixed export file
dest = " F:\epurchasing\data\
exportfix.csv"
// **
f.open(fid)
g.create(dest)
do while not f.eof( )
line = f.gets(200,chr(0x0A))
g.puts(line)
enddo
f.close()
g.close()
return
JM
JOHN PHILLIPS Wrote:
> Can't append a .txt file that is tab seperated
> any suggestions
| |
| Roland Wingerter 2006-01-07, 7:23 am |
| JOHN PHILLIPS wrote
> Can't append a .txt file that is tab seperated
> any suggestions
------
Check out Ken Mayer's importData.wfm in the dUFLP.
Roland
| |
| John Phillips 2006-01-08, 1:23 pm |
| Roland Wingerter Wrote:
> JOHN PHILLIPS wrote
> ------
> Check out Ken Mayer's importData.wfm in the dUFLP.
>
> Roland
>
>
I've been trying to get results from importData.wfm but have had no luck Main problem I'm guessing is I'm running Visual 7.5
trying to import data from a text file with the fields seperated by Tab
Is there a way to swith the txt file ti DOS?
anyoher sugg. ?
| |
| Roland Wingerter 2006-01-08, 8:23 pm |
| John Phillips wrote
> Roland Wingerter Wrote:
> I've been trying to get results from importData.wfm but have had no luck
> Main problem I'm guessing is I'm running Visual 7.5
-------
I think you would have to use an earlier version of the dUFLP, which does
not use source aliases. (I don't remember when source aliases were
introduced). Check Ken Mayer's website:
www.goldenstag.net/dbase
Maybe you'll find a dUFLP version which will work with VdB 7.5.
Or you might try to add the dUFLP directory to you search path and delete
the source aliases in the dUFLP source code.
Or maybe you can use the program below, which uses low level file methods to
read the data.
Hope this helps
Roland
// Program requires stringEx.cc from the dUFLP
// Place one copy of stringEx.cc into the current directory
// or use explicit path.
set procedure to stringEx.cc additive
local cTextfile, cTargetDBF, cSeparator, cEndOfLine
local f, q1, r1, rf
local cLine, aFields, nRows, nMaxLineLength
cTextfile = getFile("*.csv", "Name of import file", false, "csv,txt")
if empty(cTextfile)
return
endif
cTargetDBF = getFile("*.dbf", "Destination table", false, "dbf")
if empty(cTargetDBF)
return
endif
// Change these values as appropriate
nMaxLineLength = 2000
cSeparator = ";"
cEndOfLine = CHR(13)+CHR(10)
f = new File( )
if f.exists(cTextFile)
f.open( cTextFile, "R" )
endif
q1 = new query()
q1.sql := [select * from '] + cTargetDBF + [']
q1.active := true
r1 = q1.rowset
rf = q1.rowset.fields
nRows = 1
do while not f.eof( )
// Read one line from input file
cLine = f. gets(nMaxLineLength,
cEndOfLine)
// Create array, breaking string at separator
aFields = new stringEx().breakString(cLine, cSeparator, true)
if aFields.Size = rf.Size
if r1.beginAppend()
for i=1 to rf.size
if rf[i].type $ " NUMERIC,FLOAT,LONG,D
OUBLE"
rf[i].value := val(aFields[i])
else
rf[i].value := aFields[i]
endif
next i
r1.save()
nRows++
endif
endif
enddo
f.close( )
msgbox("Number of rows imported "+ltrim(str(nRows)),"Finished import")
| |
| Gerald Lightsey 2006-01-08, 8:23 pm |
| On Sun, 08 Jan 2006 13:26:52 -0500, in the dbase.getting-started group,
John Phillips said...
> I've been trying to get results from importData.wfm but have had no
> luck Main problem I'm guessing is I'm running Visual 7.5
>
> trying to import data from a text file with the fields seperated by Tab
> Is there a way to swith the txt file ti DOS?
> anyoher sugg. ?
Open the file in MS Excel and then save it as DBF4.
Gerald
|
|
|
|
|