
Unfortunately LC doesn't get the last columns like that
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Unfortunately LC doesn't get the last columns like that
Mostly the 2nd code listed was a mistaken copy/paste, however, even when I corrected it, there was little to no difference in the speed. Here is the *correct* code that should have been put in that post:SparkOut wrote: ↑Tue Feb 25, 2025 8:20 pmHey bogs, why would you update the field like that in the loop?
A) field uodates are a hefty overhead
B) you have two statements that put data into an indexed line, which means that twice within each loop the engine has to count through to the index to update each.
Surely a more comparative test would be to put the extracted data "after" or even "before" a variable, then drop that data into the field in one go.
Notwithstanding, the array split is a brilliant method, but relies on data being consistently sane.
Anyone producing insane data for others to manipulate surely is insane, or a sadist.
Code: Select all
on mouseUp
put empty into field 1; put empty into field 2; put empty into field 3
--lock screen
put the seconds into tmpStart
put url("file:/home/b/Desktop/LiveCodeProjects/exampleProjects/largeCsvDatasetHandling/Electric_Vehicle_Population_Data.csv") into tData
set the itemDelimiter to comma
put 1 into theLine
repeat for each line x in tData
put theLine & " of " & the number of lines of tData /* this opens the message box to tell you how far along you are,
as the amount of time it was taking made me think my machine
had locked or the program test had frozen */
put item 6 of x into line theline of tmpFld2
put item 7 of x into line theline of tmpFld3
add 1 to theLine
wait 1 milliseconds with messages // included this to stop maxing out the CPU on the machine, it worked a charm!
end repeat
put tmpFld2 into field 2
put tmpFld3 into field 3
--unlock screen
put " Putting item 6 & 7 of each line into fields 2 & 3 took " & the seconds -tmpStart & "seconds" into field 1
end mouseUp
That would imply (to me) that if your line is indexed, the engine goes straight to that line # skipping any loops through the variable.oliver@runrev.com wrote: If you want to iterate through a large list, doing something to each item *and* keeping track of which item you are currently at, using the repeat for each form is often faster than the repeat with. For example a structure like this:Could be replaced with the faster loop below:Code: Select all
repeat with x = 1 to the number of lines of the text of field "Very Long List" doStuff line x of the text of field "Very Long List", x end repeat
The reason for this is that evaluation "line x of field..." requires Revolution to loop down through the field until it finds the correct line.Code: Select all
local tLineNumber put 1 into tLineNumber repeat for each line tLine in field "Very Long List" doStuff tLine, tLineNumber add 1 to tLineNumber end repeat
Well, they delimit different things, certainly. There is a rowDelimiter as well and it delimits... wait for it... ROWS !!!richmond62 wrote: ↑Wed Feb 26, 2025 3:18 pmSo: obviously itemDelimiter and columnDelimiter work differently.
You made my day, my love.it delimits... wait for it... ROWS !!!
I disagree, I think it added considerable value, since you actually tested it instead of making assumptions, and then reported the result.
You can see this problem being made every time you see a program that doesn't test for input (if you can form a test for the input, if you can't you can still delimit it properly) or, oddly enough, accepts partially formed input, or doesn't put the input given in a coherent form. Some examples would be:
I suspect a lot of the delay in the testing bogs did might have been from the updates made in the message box. That would certainly create an overhead in field display updates.