我有这样的文本文件:
"01","AAA","AAAAA"
"02","BBB","BBBBB","BBBBBBBB"
"03","CCC"
"04","DDD","DDDDD"
我想将此文本文件数据加载到 sybase db 中的临时表中。所以,我需要构建一个程序来逐行读取这个文本文件,直到 eof。如果文本文件很小,则逐行读取的过程很快。但是如果文本文件太大(可以超过500M),逐行读取的过程太慢了。我认为逐行读取方法不适合巨大的文本文件。因此,需要找到其他解决方案将文本文件数据加载到 db 中,而不是逐行读取文本文件的方法。有什么建议吗?示例代码:
var
myFile : TextFile;
text : string;
begin
// Try to open the Test.txt file for writing to
AssignFile(myFile, 'Test.txt');
// Display the file contents
while not Eof(myFile) do
begin
ReadLn(myFile, text);
TempTable.append;
TempTable.FieldByName('Field1').asstring=Copy(text,2,2);
TempTable.FieldByName('Field2').asstring=Copy(text,7,3);
TempTable.FieldByName('Field3').asstring=Copy(text,13,5);
TempTable.FieldByName('Field4').asstring=Copy(text,21,8);
TempTable.post;
end;
// Close the file for the last time
CloseFile(myFile);
end;