Home > Back-end >  Questions about the read TXT file, a great god
Questions about the read TXT file, a great god

Time:09-25

Basic is like this, now I want to read TXT file of data, such as a total of four columns, the first column, I want to read alone after three columns to read for the subsequent calculation, how to code, please?

CodePudding user response:

OpenDialog1. InitialDir:=Path;
OpenDialog1. Filter:='Text Files (*.txt) | *. TXT | All Files (*. *) | *. *';
If OpenDialog1. Execute then
Path1:=OpenDialog1 FileName
The else
The begin
Path1:=';
exit;
end;
AssignFile (Fname, Path1);
Reset (Fname);
J:=0;
While (not Eof (Fname)) And (j & lt; PN) do
The begin
For I:=0 to 0 do
Read (Fname, depthaa [j] [I]);

Showmessage (' tongguo ');

For I:=1 To NdNum [0] Do
Read (Fname, xp [j] [I]);
This is part of the code

CodePudding user response:

Can build a stringlist variables, TXT files loaded, loop out 4 rows of data saved in the temporary database,

CodePudding user response:

Agree with upstairs,
Use TStringList most convenient, the four columns in the line of values can be in the form of a subscript, such as MysList [0], is a string type, and then you to convert the types and corresponding calculation, so the premise is if is calculated with a row,

If an inter-bank data calculation, such as the sum of a column, can recycling,

If an inter-bank again more complicated calculation, it is better to loop over the processing to the table, and then use the database to do

Don't know what do you want to do, so all sorts of situations are said to you
  • Related