I’m working with a 38,000 rows file. I’ve tried a loop script to look for a value in those rows but it takes a very long time to get the result. How should I modify it to be work full ? Perhaps by using range, but I don’t know how to use it. Could you please help me?
tell application "Numbers"
activate
tell the first table of the sheet "feuille 1" of the document "TOUT"
set titre_saisi to display dialog "Saisir le titre recherché" default answer "" buttons {"OK"} default button 1
set titre to text returned of titre_saisi
set liste_titre to {}
repeat with n_titre from 1 to row count
if the value of cell 1 of row n_titre contains titre then
set end of liste_titre to the value of cell 1 of row n_titre
end if
end repeat
set clic to choose from list liste_titre with prompt "Choisir le titre"
end tell
end tell
script o
property available : {}
end script
set docName to "TOUT.numbers"
set docAlias to ((path to desktop as text) & docName) as alias
tell application "Numbers"
activate
open docAlias
tell table 1 of sheet "feuille 1" of document docName
set titre_saisi to display dialog "Saisir le titre recherché" default answer "" buttons {"OK"} default button 1
set titre to text returned of titre_saisi
set liste_titre to {}
# Extract the value of every cells of column 1
# I use a generic scheme.
set n1 to name of cell 1 of column 1
set n2 to name of last cell of column 1
set o's available to value of cells of range (n1 & ":" & n2)
repeat with maybe in o's available
if (maybe as text) contains titre then
set end of liste_titre to maybe
end if
end repeat
set clic to choose from list liste_titre with prompt "Choisir le titre"
end tell
end tell
As you may see, here I was forced to add the suffix “.numbers” at the end of the document name.
Using a property defined in the script object o is an old trick which fasten the treatment of long lists.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 18 décembre 2019 19:55:56
As I wrote in my first message, it’s a ‘trickery’ used for years which fasten the treatment of lists, mostly the large ones.
The same in French:
Définir une liste en tant que propriété (par opposition à une variable classique) est une astuce repérée de longue date pour accélérer le traitement des listes.
Je la place à l’intérieur d’un objet script afin qu’elle ne soit pas enregistrée dans le fichier du script.
When you will see this message, the script available in my original message will be modified.
I decided to use a generic scheme to define the used range.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 18 décembre 2019 20:49:57