Recent

Author Topic: howto Load CSV file to StringList and then to TStringGrid (for dummy's)  (Read 12290 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: 4459
  • 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
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

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

Bart

 

TinyPortal © 2005-2018