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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

append from question 1

Status
Not open for further replies.

wawalter

Programmer
Aug 2, 2001
125
0
0
US
Hi,

I'm having some trouble append a text file into a dbf using VFP 7. I have tried outputting the file with tab or | and using append from file.txt delim with tab and delim with character | and I get the same problem for both.

If a field begins with a " it strips the quotes and moves the rest of the string in to the next field which messes up all the fields after that.

Bob "The Man" Smith works fine.

"The Man" Bob Smith ends up with The in the correct field and Man Bob Smith in the next field pushing all remaining fields to the right.

Thanks for any help.
 
Have you tried using a comma?

This worked properly for me:

I created a file name SomeFile.txt, containing these lines:
Code:
Bob "The Man" Smith,"123",123
"The Man" Bob Smith,"234",234

Created a table with the following structure:
Code:
1 TYPE    Character 25 
2 cAmount Character  5
3 nAmount Numeric    4

Then I used:
Code:
APPEND FROM SomeFile.txt DELIMITED WITH ','



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thanks for the reply Dave.

There can also be commas in some of the fields (I should have mentioned that) which I think would cause problems with this solution. That's why tabs or pipes worked well, until now, because they never show up in the data.
 
I think you need something like:

Code:
APPEND FROM .... DELIMITED WITH "" CHARACTER "|"

I'm not sure about the string immediately after the WITH. The aim is to tell it not to surround character fields with a special delimiter, hence the blank string. But it might work.

Whenever I need to append from a text file, I end up doing a lot of trial and error.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
That worked. Thanks!

Code:
APPEND FROM file.txt DELIMITED WITH "" WITH CHARACTER "|"
 
Hi: I have a table called "contact" with 40 fields of info about the person (simple character and numeric fields.(no memo or indices. . .and only want the raw data field values. .used Copy Structure command to create Backupcontact so both are the same field names & sizes and kind.)

My table name is "contact.dbf"
My backup table name is "backupcontact.dbf"
I merely want to go to bottom "last" record of "contact" and append
that last record to "backupcontact.dbf"

Am using this:

Select Contact
Set Order to
Go Bott
Select Backupcontact
Append Blank
Replace Backupcontact.First with Contact.First
Replace backupcontact.Mid with contact.Mid
(. . . . etc. . .all 40 field values even if some
are empty or blank)

Have looked at all the help files
and wonder if there is a more elegant or smarter way of doing this!!!

Appreciate any feedback!
THX
Mike
 
mccartmd,
There are literally many ways to do that.

Code:
Select Contact
Set Order to
Go Bott
Scatter name oRecord

insert into Backupcontact from name oRecord

Cetin Basoz
MS Foxpro MVP, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top