Hi shantastik,
Here is a script fitting your question, written by Yvan Koenig. You'll see some differences in approach from the script above.
Instructions (in French, followed by the same instructions in English) are included in the notes at the beginning of the script.
Regards,
Barry
--{code}
--[SCRIPT forNewbie-2012-05-27]
(*
Enregistrer le script en tant que Script : forNewbie-2012-05-27.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Bibliothèque:Scripts:Applications :Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Aller au menu Scripts , choisir Numbers puis choisir “forNewbie-2012-05-27”
Le script demande de sélectionner un fichier CSV,
l’ouvre avec Numbers,
insère une colonne à droite de la colonne A
puis rempli les cellules de la nouvelle colonne B ainsi créée.
--=====
L’aide du Finder explique:
L’Utilitaire AppleScript permet d’activer le Menu des scripts :
Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case “Afficher le menu des scripts dans la barre de menus”.
Sous 10.6.x et plus récents,
aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
--=====
Save the script as a Script : forNewbie-2012-05-27.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
You may have to create the folder Numbers and even the folder Applications by yourself.
Go to the Scripts Menu, choose Numbers, then choose “forNewbie-2012-05-27”
The script urge you to select a CSV file,
open it with Numbers,
insert a column on the right of column A
then fill the cells of the newly created column B.
--=====
The Finder’s Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the “Show Script Menu in menu bar” checkbox.
Under 10.6.x and higher,
go to the General pane of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2012/05/27
*)
--=====
onrun
myactivateGUIscripting()
(*
Use choose file to locate the CSV file to open *)
choose file of type {"public.comma-separated-values-text"}
tellapplication "Numbers"
(*
Open the CSV file *)
openresult
telldocument 1 totellsheet 1 totelltable 1
add column aftercolumn 1
set value of cell "B1" to "name"
setdelimtomygetLocalizedDelimiter()
(*
Build the formula =C2&" "&D2&" "&E2 and insert it in B2 *)
set value of cell "B2" to "=C2&" & quote & space & quote & "&D2&" & quote & space & quote & "&E2"
(*
Build the formula =C3&" "&D3&" "&E3&" "&F3 and insert it in B3 *)
set value of cell "B3" to "=C3&" & quote & space & quote & "&D3&" & quote & space & quote & "&E3&" & quote & space & quote & "&F3"
(*
Select the range to fill *)
setselection rangetorange ("B3 : " & nameoflastcellofcolumn 2)
endtell
endtell
(*
Fill the selected range *)
my selectSubMenu("Numbers", 5, 10, 2) (* Fill Down *)
endrun
--=====
(*
Set the parameter delimiter which must be used in Numbers formulas
*)
ongetLocalizedDelimiter()
ifcharacter 2 of (0.5 astext) is "." then
return ","
else
return ";"
endif
endgetLocalizedDelimiter
--=====
onactivateGUIscripting()
(* to be sure than GUI scripting will be active *)
tell application "System Events"
ifnot (UI elements enabled) thenset (UI elements enabled) totrue
endtell
endactivateGUIscripting
--=====
(*
my selectSubMenu("Pages",6, 4, 26)
==== Uses GUIscripting ====
*)
onselectSubMenu(theApp, mt, mi, ms)
activateapplicationtheApp
tellapplication "System Events" totellapplication processtheApptotellmenu bar 1 to ¬
tellmenu bar itemmttotellmenu 1 totellmenu itemmitotellmenu 1 toclickmenu itemms
endselectSubMenu
--=====
--[/SCRIPT]
--{code}