Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tore Bleken
  Where is Tore Bleken?
 Stokke
 Norway
 Tore Bleken
 To: Ahsan Rana
  Where is Ahsan Rana?
 Lahore
 Pakistan
 Ahsan Rana
 Tags
Subject: RE: Text File to DBF
Thread ID: 394056 Message ID: 394063 # Views: 42 # Ratings: 4
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Monday, December 30, 2013 11:12:01 AM         
   


> >
> >
> >
> >
APPEND FROM your.txt TYPE DELIMITED WITH TAB

> >
> >
> >
> > hth
> > -Stefan
>
> Thanks Stefan for reply. I am using the following code to append data from text file but it does not append data and dbf is empty
>
>
> CREATE CURSOR dAttend (No c(10),TmNo c(10),EnNo c(10),Name c(50),GmNo c(10),Mode c(10),DateTime c(50))
> APPEND FROM Attend.txt TYPE DELIMITED WITH TAB
> 


Your problem is that the text file clearly is a double byte file. I found out this by using the tool HexEdit.app which comes with VFP.

lcFile = 'Attend.txt'
Do Addbs(Home()) + [tools\hexedit\hexedit.app] With lcFile

You can fix this easily.

strtofile(chrtran(filetostr('Attend.txt'),chr(0),''),'Attend.txt')
APPEND FROM Attend.txt TYPE DELIMITED WITH TAB

One line of caution. You use Name and DateTime as field name. These are reserved words, and may cause strange errors. I suggest for instead AttName and AttDT instead.

There's a fine line between helping and adding to the confusion.

How to create sample data

ENTIRE THREAD

Text File to DBF Posted by Ahsan Rana @ 12/30/2013 9:32:42 AM
RE: Text File to DBF Posted by Tore Bleken @ 12/30/2013 9:42:58 AM
RE: Text File to DBF Posted by Stefan Wuebbe @ 12/30/2013 9:49:35 AM
RE: Text File to DBF Posted by Ahsan Rana @ 12/30/2013 10:26:52 AM
RE: Text File to DBF Posted by Stefan Wuebbe @ 12/30/2013 10:48:36 AM
RE: Text File to DBF Posted by Ahsan Rana @ 12/30/2013 11:18:55 AM
RE: Text File to DBF Posted by Tore Bleken @ 12/30/2013 11:12:01 AM
RE: Text File to DBF Posted by Ahsan Rana @ 12/30/2013 11:27:29 AM
RE: Text File to DBF Posted by Tore Bleken @ 12/30/2013 11:32:27 AM
RE: Text File to DBF Posted by michael johnson @ 12/30/2013 11:31:53 AM
RE: Text File to DBF Posted by Cetin Basoz @ 12/30/2013 12:23:48 PM
RE: Text File to DBF Posted by Tore Bleken @ 12/30/2013 1:35:57 PM
RE: Text File to DBF Posted by Cetin Basoz @ 12/30/2013 6:58:53 PM