Re: How to sort out this
Posted: Sun Jul 22, 2018 8:40 pm
Maybe you can post 50 lines or so here for testing. Plain text please.
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
I've uploaded the file in different host and in zip format. let me know if you have issue downloading the file:jacque wrote: Sun Jul 22, 2018 8:40 pm Maybe you can post 50 lines or so here for testing. Plain text please.
Code: Select all
http://www.mediafire.com/file/c00yhr2z79r3uy6/sample.zipCode: Select all
on mouseUp
local tList, tKey, tLines, tCounts, tDupes, tStart
set the itemDel to ":"
put the millisecs into tStart
put url ("file:" & field "FileName") into tList
-- look at each line in the original data
repeat for each line tLine in tList
put item 1 of tLine into tKey
put item 2 of tLine into tLines[tKey]
add 1 to tCounts[tKey]
end repeat
-- go through array and remove dupes
repeat for each key tKey in tLines
if tCounts[tKey] > 1 then
delete variable tLines[tKey]
end if
end repeat
combine tLines using return and ":"
set the text of field "Destination" to tLines
answer the millisecs - tStart
end mouseUp
already done trying your latest code. its working like a charm. seems I've got expected result by checking so far. a BIG SALUTE for youbwmilby wrote: Sun Jul 22, 2018 8:51 pm Well, I don't think the lineoffset method is viable for the real file. I let it run for >10 min and it still didn't finish.
The below code took between 18 and 23 sec for the actual data (first file - .7z)
HowToSortOutThis.livecode.zipCode: Select all
on mouseUp local tList, tKey, tLines, tCounts, tDupes, tStart set the itemDel to ":" put the millisecs into tStart put url ("file:" & field "FileName") into tList -- look at each line in the original data repeat for each line tLine in tList put item 1 of tLine into tKey put item 2 of tLine into tLines[tKey] add 1 to tCounts[tKey] end repeat -- go through array and remove dupes repeat for each key tKey in tLines if tCounts[tKey] > 1 then delete variable tLines[tKey] end if end repeat combine tLines using return and ":" set the text of field "Destination" to tLines answer the millisecs - tStart end mouseUp
Hi, Alemrantareq.bwmilby wrote: Sun Jul 22, 2018 7:32 pm The goal is to completely remove any key that is repeated (not just the duplicates).
...
Does it work for you?function singletonKeys pLines, pItemDelimiter
local tAllKeys, tPriorKey, tDuplicatedKeys, tSingletonKeys
sort pLines
set the itemDelimiter to pItemDelimiter
repeat for each line tLine in pLines
get item 1 of tLine
if it is tPriorkey then
put "true" into tDuplicatedKeys[ it ]
else
put item 2 of tLine into tAllKeys[ it ]
put it into tPriorKey
end if
end repeat
difference tAllKeys with tDuplicatedKeys into tSingletonKeys
combine tSingletonKeys with return and pItemDelimiter
return tSingletonKeys
end singletonKeys
Thanks, bogs. I just decided to compare a similarly instrumented edition of bwmilby's version (i.e., without accessing any field).
Code: Select all
on mouseUp
answer file "Select the File:" with type "Text File|txt"
put url ("file:" & it) into Temp
set the text of fld "f1" to singletonKeys(Temp)
end mouseUp
function singletonKeys pLines, pItemDelimiter
local tAllKeys, tPriorKey, tDuplicatedKeys, tSingletonKeys
sort pLines
set the itemDelimiter to pItemDelimiter
repeat for each line tLine in pLines
get item 1 of tLine
if it is tPriorkey then
put "true" into tDuplicatedKeys[ it ]
else
put item 2 of tLine into tAllKeys[ it ]
put it into tPriorKey
end if
end repeat
difference tAllKeys with tDuplicatedKeys into tSingletonKeys
combine tSingletonKeys with return and pItemDelimiter
return tSingletonKeys
end singletonKeysCode: Select all
set the text of fld "f1" to singletonKeys(Temp, ":")What does "got my LC crashed" mean? Do you have any evidence to share?alemrantareq wrote: Tue Jul 24, 2018 6:57 pm hi bwmilby, if you are talking about this:still no success, got my LC crashed while filteringCode: Select all
set the text of fld "f1" to singletonKeys(Temp, ":")![]()