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

how can I put the records in table

Status
Not open for further replies.

zsnemeth

Programmer
Jul 10, 2001
1
RO
how can I put the records in table from textfile?
 
Depending on the format of the text file, the way you pick the data off it may vary, but based on a csv file, you use pos to locate the ',' then copy the text to that point, and insert that value into the field in the table.

Generally, should be something like:

var
t: textfile;
l: string;

begin
AssignFile(T, 'd:\log.txt');
Reset(T);
while not eof(t) do
begin
readln(t,l);
table1.insert;
//process file entry - then table1.fieldbyname('whatever').AsString := processed value;
table1.post;
end;
closefile(T);
end;
 
Look at the DBE help file under TEXT

Eg If text File is csv create a file with The same name as the text file you are working with but with .sch as the extension.
ACCLIST.TXT create ACCLIST.SCH

Create These Two File An You Will Se What I Mean
In The ACCLIST.SCH put The Folling

[ACCLIST]
Filetype=VARYING
Delimiter="
Separator=;
CharSet=ascii
Field1=Accno,String,30,00,0
Field2=Add1,String,30,00,30
Field3=Add2,String,30,00,60


In ACCLIST.TXT

1234;Any Road;AnyTown


Place a new table on a form. DATABASE NAME should point to
the location of the ACCLIST.TXT . The SCH file should be at same location.

TABLENAME = ACCLIST.TXT and TableType = ttAscii

when you open the table the text file data will read directly into table.

Read The DBE HELP it Will List More detail. This Should Get You Started.

 
var
t: textfile;
l: string;

begin
AssignFile(T, 'd:\log.txt');
Reset(T);
while not eof(t) do
begin
readln(t,l);
table1.appendrecord([l]);
end;
closefile(t);
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top