| |

VerySource

 Forgot password?
 Register
Search
Author: yunshenxin

Text deduplication algorithm problem ~~ Please give pointers

[Copy link]

4

Threads

19

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-3-31 23:00:02
| Show all posts
Is it something wrong with my DELPHI
Reply

Use magic Report

0

Threads

25

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-4-1 11:45:01
| Show all posts
No problem. Tested many times
Reply

Use magic Report

4

Threads

19

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-4-2 14:45:01
| Show all posts
TmpStrings.Assign (TStrings (StringsList.Items [Pred (StringsList.Count)]));
Run here and it appears
Reply

Use magic Report

0

Threads

25

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Germany

Post time: 2020-4-3 12:45:01
| Show all posts
You recreate a text file and copy your text back into the new text file. Your problem is that you have a blank line with a carriage return in your original text file
Reply

Use magic Report

4

Threads

19

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-4-3 16:15:01
| Show all posts
OK, 3Q
Reply

Use magic Report

0

Threads

25

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-4-3 19:45:01
| Show all posts
I modified the algorithm a bit:

..........
// Write data to List
    StringsList: = TList.Create;
    for Idx: = 0 to Pred (Memo.Lines.Count) do
    begin
      if Pos (',', Memo.Lines [Idx])> 0 then // Remove empty lines
      begin
        Strings: = TStringList.Create;
        Strings.Delimiter: = ',';
        Strings.DelimitedText: = Memo.Lines [Idx];
        StringsList.Add (Pointer (Strings));
      end;
    end;

.............
Reply

Use magic Report

0

Threads

25

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-4-4 09:45:01
| Show all posts
The more rigorous algorithm should be like this:

// Write data to List
    StringsList: = TList.Create;
    for Idx: = 0 to Pred (Memo.Lines.Count) do
    begin
      Strings: = TStringList.Create;
      Strings.Delimiter: = ',';
      Strings.DelimitedText: = Memo.Lines [Idx];
      if Strings.Count = 5 then // Only process rows with 5 columns
        StringsList.Add (Pointer (Strings));
    end;
Reply

Use magic Report

4

Threads

19

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-4-4 15:15:01
| Show all posts
You are really good ~~ The algorithm thinks so flexible ~ Thanks
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list