Recent

Author Topic: howto Load CSV file to StringList and then to TStringGrid (for dummy's)  (Read 7871 times)

hans

  • Newbie
  • Posts: 1
Hi,
Just started with programming and with Lazarus/FPC.

I've got this CSV file from my Bank and want to process it in an application I have in mind.

After a long search I found a way to load the CSV file (TStringList.LoadFromFile(csv.txt) and a way to present it (TStringGrid) on a Form.
But? How to get the loaded data from the TStringList tot the TStringGrid.
And howto get information about the TStringList object (mutaties). Information like i.e. size.

Any suggestions (please, at dummy level. And yes I've found lots of examples with Google that didn't help me).
Thanks.

Code: [Select]
begin
  //gebruikt TStringList om de inhoud van mut.txt te lezen
  mutaties:= TStringList.Create;  //object mutaties aanmaken.
  mutaties.LoadFromFile(mutbestand);
  // object informatie. rowcountcolcount StringGrid1.
  Label3.Caption:= IntToStr(StringGrid1.RowCount);
  Label4.Caption:= IntToStr(StringGrid1.ColCount);
  Edit1.Caption:= mutaties.Delimiter;
  Edit2.Caption:= mutaties.DelimitedText;
end; 

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3610
  • I like bugs.
You are lucky! TStringGrid supports loading and saving CSV data directly. It was even improved recently. See :
  http://lazarus.freepascal.org/index.php/topic,17113.msg93955.html

Regards,
Juha

Bart

  • Hero Member
  • *****
  • Posts: 3452
    • Bart en Mariska's Webstek
You need Lazarus from trunk for that, 0.9.30.x versions do not support that AFAIK.

Bart