2014-04-22 35 views
0

我得到包含以列格式的數據的文本文件,通過;分離(該文件的來源是被R創建並保存爲一個文本數據幀一個)。拉撒路:如何從一個文本到表導入數據?

Name; Date; Results; Score; 
John; 1; 100; 1 
John; 3 ; 200; 1 
John; 5; 30; 9 
Mike; 1; 90; 2 
Mike; 3; 34; 10 
Mike; 5; 216; 1 
... 

我想將這些數據框導入到Lazarus中聲明的表中。 這是我開始做:

Type 
TRunning=record 
Date, Score: array [1..3] of integer; ## since I have 3 datas per name 
Results: array [1..3] of double; 
    Var 
Run : array [1..100] of TRunning ## since I have a total of 100 names 

你能幫我從文本文件做進口數據?

回答

2

使用TStringList.LoadFromFile()它使用ExtractStrings :

procedure TForm1.FormCreate(Sender: TObject);  
     var 
      rowlist,collist:TStringList; 
      i:integer 
     begin 
      rowlist:=TStringList.Create; 
      collist:=TStringList.Create; 
      rowlist.LoadFromFile('filename'); 
      for i:=0 to rowlist.Count-1 do 
      begin 
       ExtractStrings([';'],[''],PChar(rowlist.Strings[i]),collist); 
       //fill your table with collist 
      end; 
     end;  
+0

非常感謝ExtractString功能創造stringlist形式埃夫裏排在你的文件,然後從你的數據 提取colomn字符串。但是,如何使用「collist」字符串列表填充我的表格? (這個步驟是我過的最困難的實現) – Remssssss

+0

你這是什麼意思表?你的意思是StringGrid? – mabudrais

+0

我的意思是在我的紀錄 – Remssssss

相關問題