0

Tell me how to DIUnicode read the rows user define for example start with rows 8? For example I start with rows 8 until 11 this one payment ..etc

===========================================
|Period 01.01.2012  31.12.2012
Saldo  01.01.2012            
----------------------------------------------------------------
|   Date        | Correspondet: Bank/account/Tax Name                     | 
| Payment       | Remark                                                  |   
----------------------------------------------------------------          |
|04.01.2012     | Bank:00883  account:200004000000005936111  tax:000000000|
|               |paynet                                                   |
|               |00644blbalbalbalbalbalbalbalN-4774                       |
|               |  24.03.2010                                             |
----------------------------------------------------------------
|06.01.2012     |BANK:00883  account:200004000600005000111  tax:000000000 |
|               |paynet                                                   |
|               |00644blablbalbalbalbalbalblab-4774                       |
|               |  24.03.2010 
-------------------------------------------------------------------------- 
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Ulugbek
  • 43
  • 1
  • 7
  • 1
    Read line by line while counting them. Start your work, if your counter is greater than 7? – Sir Rufo Mar 18 '13 at 06:39
  • 1
    What have you tried? Show some code. We can't tell whether you are an expert Delphi programmer or a total novice. Perhaps you don't know how to create an object. We can't tell. Which Delphi version? – David Heffernan Mar 18 '13 at 08:05
  • I'd use `TStringList.LoadFromFile`, then read lines `7,8,9,... Pred(.Count)` Modern Delphi versions have SL able to read unicode files, for deprecated versions there are 3rd party stringlists unicode-capable. – Arioch 'The Mar 18 '13 at 08:37
  • OK Delphi version Xe3 and i will be try Can you share code.. I will be try how read for example for i=0 to stringlist.count-8 do begin data = copy(stringlist[i],2,10) bank = copy(stringlist[i],16,5) how read other rows example 2,3,4 because 4 rows one document insert into table () end – Ulugbek Mar 18 '13 at 09:34
  • Delphi version should go as tag. Now, what do u mean by "to DIUnicode"? why do you want to use Delphi Inspirations lib for starters ? And why did you mentioned Unicode while your text seems regular central-european ? – Arioch 'The Mar 18 '13 at 10:31
  • Why are you using DIUnicode? Do you need an encoding that Delphi does not support out of the box? – David Heffernan Mar 18 '13 at 11:51
  • @David test is most probably windows-1251 http://www.sql.ru/forum/actualthread.aspx?tid=1011211 However with TStringLsit of XEx AFAIR can auto-detect UTF-8 – Arioch 'The Mar 18 '13 at 12:12

1 Answers1

0

With the given sample the most easy thing is to use stirnglizst and iterate every line but initial 7 lines.

I also don't know why u told about diUnicode library. But i assume that your file is encoded in UTF8. If it actually uses another flavour of Unicode or non-Unicode at all, then change the code accordingly.

var sl: TStrings; s: String; i: integer;
begin
    sl := TStringList.Create;
    try
       sl.LoadFromFile('c:\Table.txt', TEncoding.UTF8);
       for i := 0 to 7 do sl.Delete(0); 

       for s in sl do begin
            // do some work with s 
           ShowMessage(Copy(s,18, Length(s)));
       end;
    finally
      sl.Free;
    end;
end;

You may also try to make internal parsing of string, using two advanced stringlists, like in Split a string into an array of strings based on a delimiter

var slF, slR: IJclStringList; l, s: string; 

slF := TJclStringList.Create; slF.LoadFromFile('table.txt');
slR := TJclStringList.Create;

slF.Delete(0).Delete(0).Delete(0).Delete(0).Delete(0).Delete(0).Delete(0); // delete top 7 lines

for l in slF do begin
    if StartsStr('-----', l) then continue; // skip separator

    slR.Split(l, '|', true).Trim;

    for s in slR do {nothing or something} Application.Title := s ;
    ShowMessage('Date or void: '+ slR[0]);
    ShowMessage('Transfer details: '+ slR[1]);
end; 
slF := nil; slR := nil;
Community
  • 1
  • 1
Arioch 'The
  • 15,799
  • 35
  • 62