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

Appending from TXT file 3

Status
Not open for further replies.

SitesMasstec

Programmer
Sep 26, 2010
526
Brasil
Dear colleagues:

I have a CUSTOMER.TXT file like this one (but with more data):

"500002907113016","890003964225679","650003964225674","767003268777832",...

I wish to populate a empty table with records.

I opened the table (CUSTOMER.DBF, with just one field named Account, type Character, size 15) and execute the command:
APPEND FROM CUSTOMER.TXT TYPE DELIMITED WITH CHARACTER , WITH "
but only the first record was created (record 1: 500002907113016)

How to generate the other records?

Thanks,
SitesMasstec

 
Your sample data shows all the fields on a single line. If that's how the file actually looks, then you will only append one record. That's because VFP is looking for a carrriage return / line feed to terminate the line:

VFP Help File said:
A delimited file is an ASCII text file in which each record ends with a carriage return and line feed.

You will need to get each record onto a separate line. One way to do that would be like this:

Code:
lcText = FILETOSTR("customer.txt")
lcText = STRTRAN(lcText, ",", CHR(13) + CHR(10))
STRTOFILE(lcText, "customer.txt")

Then go ahead and do the Append.

(I'm assuming that each record consists only of the one field, for example "500002907113016". If that's not the case, perhaps you could explain the structure of the text file in more detail.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
VFP expects every record to end with a carriage return. Try this:
[pre]
lcFile = 'customer.txt'
strtofile(strtran(filetostr(lcFile),',',',' + chr(13) + chr(10)),lcFile)
Append from...
[/pre]
 
Yes Mike, the CUSTOMER.DBF has just one field.

I got the expected result, thank you Mike and Tbleken.

SitesMasstec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top