"Text to Column" 's excel equivalent in Numbers

Anyone who knows what is the equivalent function of "text to column" in excel to Numbers?

thanks,

MAcbook Pro, 2.33 GHz, Mac OS X (10.6)

Posted on Sep 7, 2009 6:09 PM

Reply
12 replies

Sep 8, 2009 6:11 AM in response to Badunit

Thre is a TRANSPOSE() function in Numbers '09 but it is not easy to use.

You may go to my iDisk:
<http://idisk.me.com/koenigyvan-Public?view=web>
and download :
For_iWork:iWork '09:for_Numbers09:Transpose.zip
This archive contains two scripts.
One allow you to build a frozen transposed table (was written for Numbers '08)
One allow you to build a living table whose cells's contents will change when the original ones are modified.
It would be your duty to enlarge the table ifrows or columns are added to the source but, as every cells are filled adding new row/column will automatically insert the correct formulas.

Yvan KOENIG (VALLAURIS, France) mardi 8 septembre 2009 15:11:31

Sep 13, 2009 2:03 PM in response to Badunit

I wonder if MS got a patent on that function?
Have to stick to Microsoft Excel for that reason - much easier to use that the cumbersome function.
I found some function that of you import .csv into Numbers and even Excel it will automatically separate it to different columns, but that is not enough if you got so many text series that you wanted to import in to a single file and wish to use that function.

Sep 14, 2009 2:54 AM in response to Badunit

Thanks Badunit

Here is a script doing the trick

--

--[SCRIPT split_string]
(*
Enregistrer le script en tant que Script ou Progiciel : split_string.xxx
déplacer le fichier créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
sélectionner une cellule contenant la chaîne à découper
menu Scripts > split_string
Le script découpe en utilisant virgule ou point virgule comme séparateur
puis colle le résultat à partir de la cellule source.
--=====
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".
+++++++
Save the script as Script or an Application Bundle: split_string.xxx
Move the newly created application into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a cell containing the string to split.
menu Scripts > split_string
The script will split using comma (or semi colon) as separator
then paste the result starting from the source cell.
--=====
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.
--=====
Yvan KOENIG (VALLAURIS, France)
2009/09/14
*)
on run
my activateGUIscripting()
set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
set enTexte to value of cell rowNum1 of column colNum1
if enTexte contains "," then
set delim to ","
else
set delim to ";"
end if
set target to name of cell rowNum1 of column colNum1
set target to target & " : " & target
set selection range to range target

set the clipboard to my remplace(enTexte, delim, tab)
my shortcut("Numbers", "v", "c")
end tell
log target
end run
--=====
on getSelParams()
local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
set {d_Name, s_Name, t_Name, r_Name} to my getSelection()

if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if

set two_Names to my decoupe(r_Name, ":")
set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
if item 2 of two_Names = item 1 of two_Names then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
end if
return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end getSelParams
--=====
(*
set {rowNumber, columnNumber} to my decipher(cellRef,docName,sheetName,tableName)
apply to named row or named column !
*)
on decipher(n, d, s, t)
tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
end decipher
--=====
(*
set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
*)
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum

tell application "Numbers" to tell document 1
repeat with i from 1 to the count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on remplace(t, d1, d2)
local l
set AppleScript's text item delimiters to d1
set l to text items of t
set AppleScript's text item delimiters to d2
set t to l as text
set AppleScript's text item delimiters to ""
return t
end remplace
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
on activateGUIscripting()
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true (* to be sure than GUI scripting will be active *)
end tell
end activateGUIscripting
--=====
(*
==== Uses GUIscripting ====
*)
on shortcut(a, t, d)
local k
tell application a to activate
tell application "System Events" to tell application process a
repeat with k in t
if d is "c" then
keystroke (k as text) using {command down}
else if d is in {"ac", "ca"} then
keystroke (k as text) using {command down, option down}
else if d is in {"sc", "cs"} then
keystroke (k as text) using {command down, shift down}
else if d is in {"kc", "ck"} then
keystroke (k as text) using {command down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
keystroke (k as text) using {command down, shift down, control down}
end if
end repeat
end tell
end shortcut
--=====
--[/SCRIPT]
--


I may easily enhance it to treat several cells of a given column in a single call.

Yvan KOENIG (VALLAURIS, France) lundi 14 septembre 2009 11:53:50

Sep 17, 2009 3:00 AM in response to KOENIG Yvan

Here is an enhanced version.

(1) it no longer use GUI scripting and the clipboard.

(2) it may treat a group of cells of a column in a single task.

--

--[SCRIPT texttocolumns]
(*
Enregistrer le script en tant que Script ou Progiciel : texttocolumns.xxx
déplacer le fichier créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
sélectionner une cellule ou un groupe de cellules d'une colonne contenant la (les) chaîne(s) à découper
menu Scripts > texttocolumns
Le script découpe en utilisant virgule ou point virgule comme séparateur
puis insère les différentes valeurs à partir de la cellule source.
--=====
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".
+++++++
Save the script as Script or an Application Bundle: texttocolumns.xxx
Move the newly created application into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a cell or a group of cells in a column containing the string(s) to split.
menu Scripts > texttocolumns
The script will split using comma (or semi colon) as separator
then insert the resulting values starting from the source cell.
--=====
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.
--=====
Yvan KOENIG (VALLAURIS, France)
2009/09/14
2009/09/17 treats a range and no longer use the clipboard and the GUI scripting
*)
on run
set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
repeat with r from rowNum1 to rowNum2
tell row r
set maybe to value of cell colNum1
if class of maybe is Unicode text then
if maybe contains "," then
set delim to ","
else
set delim to ";"
end if
set listeR to my decoupe(maybe, delim)
repeat with k from 1 to count of listeR
set value of cell (colNum1 - 1 + k) to item k of listeR
end repeat
end if
end tell
end repeat
end tell
end run
--=====
on getSelParams()
local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
set {d_Name, s_Name, t_Name, r_Name} to my getSelection()

if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if

set two_Names to my decoupe(r_Name, ":")
set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
if item 2 of two_Names = item 1 of two_Names then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
end if
return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end getSelParams
--=====
(*
set {rowNumber, columnNumber} to my decipher(cellRef,docName,sheetName,tableName)
apply to named row or named column !
*)
on decipher(n, d, s, t)
tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
end decipher
--=====
(*
set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
*)
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum

tell application "Numbers" to tell document 1
repeat with i from 1 to count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
--


Yvan KOENIG (VALLAURIS, France) jeudi 17 septembre 2009 12:00:14

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

"Text to Column" 's excel equivalent in Numbers

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.