unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
type
Tcandleprice = (sopen, slow, shigh, sclose);
Tcandle = record
sdate: string[20];
stime: string[5];
candleprice: array [Tcandleprice] of word;
ivolume: integer;
end;
Tcandles = array of Tcandle;
var
Form1: TForm1;
candles: Tcandles;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
filename: string;
sr: TStreamReader;
sl: TStringList;
total, blocksize: integer;
i, anzahlkerzen: integer;
sepstring: char;
aline: string;
begin
anzahlkerzen :=0;
Sepstring := FormatSettings.DecimalSeparator;
filename := '[DAX30]5.csv';
sl := TStringList.Create;
sr := TStreamReader.Create(filename, true);
sl.Capacity := sr.BaseStream.Size div 100;
total := 0; // Total number of lines in the file (after it is read in)
blocksize := 10000; // The number of lines per "block"
try
sl.BeginUpdate;
try
while not sr.EndOfStream do
begin
sl.Clear;
while not (sl.Count >= blocksize) do
begin
sl.Add(sr.ReadLine);
total := total + 1;
if (sr.EndOfStream = true) then break;
end;
//
Handle the current block of lines here
for i := 0 to sl.Count-1 do
begin
SetLength(candles, Length(candles)+1);
aline := sl[i];
candles[AnzahlKerzen].sdate := Copy((aline), 1, Pos(',',(aline))-1);
Delete(aline, 1, Pos(',', (aline)));
candles[AnzahlKerzen].stime := Copy((aline), 1, Pos(',', (aline))-1);
Delete(aline, 1, Pos(',', (aline)));
candles[AnzahlKerzen].candleprice[sopen] := StrtoInt(StringReplace(Copy((aline), 1, Pos(',', (aline))-7),'.', sepstring,[]));
Delete(aline, 1, Pos(',', (aline)));
candles[AnzahlKerzen].candleprice[shigh] := StrToInt(StringReplace(Copy((aline), 1, Pos(',', (aline))-7),'.', sepstring,[]));
Delete(aline, 1, Pos(',', (aline)));
candles[AnzahlKerzen].candleprice[slow] := StrToInt(StringReplace(Copy((aline), 1, Pos(',', (aline))-7),'.', sepstring,[]));
Delete(aline, 1, Pos(',', (aline)));
candles[AnzahlKerzen].candleprice[sclose]:= StrToInt(StringReplace(Copy((aline), 1, Pos(',', (aline))-7),'.', sepstring,[]));
Delete(aline, 1, Pos(',', (aline)));
candles[AnzahlKerzen].ivolume := StrToInt(aline);
inc(AnzahlKerzen);
if anzahlkerzen mod 9999 = 9998 then memo1.Lines.Add('durchgang');
form1.Caption := 'Candle Bot - reading Candle Nr.:'+inttostr(AnzahlKerzen)+' from '+ ExtractFileName(filename);
end;
end;
finally
sl.EndUpdate;
end;
finally
sr.free;
sl.Free;
end;
end;