Hello!
I couldn't find any way how to find out currently processed bytes while using TCSVParser from CSVDocument component.
Imagine such code:
Parser:=TCSVParser.Create;
FileStream := TFileStream.Create(FileName, fmOpenRead + fmShareDenyWrite);
ProgressBarLoadCSV.Max := FileStream.Size; {Progress bar is based on file size}
StrSize := 0;
try
Parser.Delimiter := ',';
Parser.SetSource(FileStream);
while Parser.ParseNextCell do
begin
... {Checking if additional rows, columns should be added}
ListGrid.Cells[Parser.CurrentCol, Parser.CurrentRow] := Parser.CurrentCellText;
StrSize := StrSize + CurrentlyProcessedBytes; {Is it possible to get currently processed bytes}
ProgressBarLoadCSV.Position := StrSize;
end;
finally
Parser.Free;
FileStream.Free;
end;
Problem is about variable "CurrentlyProcessedBytes". Idea is to make progress bar which is based on csv file size and currently processed bytes by TCSVParser. I couldn't find any way to find this value from TCSVParser. Most of all there is no such thing in this component.
I'm just curious is there any way to make workaround or something else?
Getting String size from TCSVParser.CurrentCellText is not a solution, because this content does not contain separators, quotes, new lines and similar symbols (bytes) which are not part of readable text.
Making progress bar based on row and column count is not a solution either, because this count is unknown before csv is parsed.
Any ideas would be greatly appreciated!
Thanks!