Page 1 of 1

recording duplicate items in a list

Posted: Sun Aug 03, 2014 10:52 am
by sims
I have a list of items such as in example list 1 shown below.

I want to record how many are the same but only the same by char 1 to 2 and char 6 to 7 then place that number of duplicates after each line, as in example list 2.
In other words: if chars 1,2,6,7 are the same as others in another line then put that total after those lines.

Any ideas for doing this?

Thanks,
sims
---
LIST 1
08:00_d3_180_Monica_pink
10:45_d2_90_Mary_orange
10:00_d2_90_Mary_orange
10:15_d2_90_Mary_orange
10:30_d2_90_Mary_orange
10:00_d2_90_Mary_orange
10:00_d2_90_Mary_orange
12:30_d5_45_Mary_blue
12:45_d5_45_Mary_blue
12:60_d5_45_Mary_blue

LIST 2
08:00_d3_180_Monica_pink_1
10:45_d2_90_Mary_orange_3
10:00_d2_90_Mary_orange_3
10:15_d2_90_Mary_orange_3
10:30_d6_90_Mary_orange_2
10:00_d6_90_Mary_orange_2
10:00_d3_90_Mary_orange_1
12:30_d5_45_Mary_blue_3
12:45_d5_45_Mary_blue_3
12:60_d5_45_Mary_blue_3

Re: recording duplicate items in a list

Posted: Sun Aug 03, 2014 1:10 pm
by jmburnod
Hi Sims,

This script seems works with char 1 to 2 and 7 to 8.
In your List 1, char 6 to 7 of each line are = _d
I think that is possible to do shorter but that is a beginning

Code: Select all

on mouseUp
   put fld 1 into tText
   put empty into tTextDef
   repeat for each line tLine in tText
      if tLine is in tTextDef then next repeat
      put char 1 to 2 of tLine into ts1
      put char 7 to 8 of tLine into ts2
      put tS1 & "????" & ts2 & "*" into tFilter
      get tText
      filter it with tFilter
      put the num of lines of it into tNbL
      if it is not in tTextDef then
         repeat with i = 1 to tNbL
            put " _" & tNbL after line i of it
         end repeat
         put it & cr after tTextDef
      end if
   end repeat
   delete char -1 of tTextDef
   put tTextDef
end mouseUp
Best regards
Jean-Marc