Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to Parse CSV data from Web pages into Numbers - text to columns inExcel

I regular need to bring in large slabs of Comma Seprated Data into spreadsheet, with excel you select the column and go /data/text to columns/.. - I can't find a way to do this in Numbers my data is all in one column, with commas - help says to drag to canvas?? - Suggestions please
small eg - need this FX data into two columns - Thanks.
06.04.2009,2.0780
07.04.2009,2.07840
08.04.2009,2.06720
09.04.2009,2.07380
10.04.2009,2.0613

Mac Mini, Mac OS X (10.6.4)

Posted on Jul 29, 2010 6:55 PM

Reply
6 replies

Jul 29, 2010 10:07 PM in response to Trevor Duck

This topic 'text to columns' has been discussed previously here; http://discussions.apple.com/thread.jspa?threadID=1074666. I don't quite understand your problem, I clipped the data in your post and pasted it into a text file using textedit and saved it as a .csv file. When I opened it in Numbers, it was already sorted into columns, delimited by the commas. If Numbers doesn't do what you want it to do you could always use Excel as your parser to do the split, save it as an xls file which will open in Numbers. A lot easier than fiddling around with scripts.

Jul 30, 2010 12:20 AM in response to nonno52

NoNo thanks for this - I tried this method before posting, but when I try to save using text edit I get no option for savig as CSV - did you save as something else and rename? eg rtf then change extension to CSV?? as for other sugg, I don't always have access to Excel so wanted a method I could use all teh time, and agree don't want to goto scripts.

Jul 30, 2010 2:11 AM in response to Trevor Duck

You may :

paste your datas in Pages
Export as Standard.
You will get a wxyz.txt file
Rename it as wxyz.csv
Open it with Numbers

Alternate soluce :
paste your datas in Pages
Apply Find/Replace to replace commas by TABs
Select All
Copy,
Paste in Numbers

I really don't understand what make you refusing script. You are using some of them daily without knowing that you do.
As I feel useful to give the most efficient soluce, here is a script which does the job by a single menu item selection.

--

--[SCRIPT insertCSV_inNumbers]
(*
Enregistrer le script en tant que Script : insertCSV_inNumbers.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:
copiez vos données depuis la page source
Aller au menu Scripts, choisir Numbers puis choisir insertCSV_inNumbers
Après conversion, les données seront insérées dans la table active de Numbers..
--=====
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,
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 Script : insertCSV_inNumbers.xxx
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:
copy datas from the source page
Go to Scripts menu, choose Numbers, then choose insertCSV_inNumbers
After conversion, the datas will be inserted in the active table in Numbers.
--=====
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,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2009/12/17
*)
--=====
property liste : {}
property liste2 : {}
on run
my nettoie()
set enTexte to the clipboard as text
if enTexte contains ";" then
set delim to ";"
else
set delim to ","
end if
set my liste to paragraphs of enTexte

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 rowMax to count rows
set colMax to count columns
set nbRows to count of liste
if rowNum1 - 1 + nbRows > rowMax then
repeat rowNum1 - 1 + nbRows - rowMax times
add row below last row
end repeat
set rowMax to count rows
end if -- nbRows + …
repeat with r from 1 to nbRows
set my liste2 to my decoupe(item r of my liste, delim)
set nbCols to count of my liste2
if colNum1 - 1 + nbCols > colMax then
repeat colNum1 - 1 + nbCols - colMax times
add column after last column
end repeat
set colMax to count columns
end if -- nbCols + …
tell row (rowNum1 + r - 1)
repeat with c from 1 to nbCols
set la_valeur to (item c of my liste2) as text
if la_valeur is "" then
clear cell (colNum1 + c - 1)
else
set value of cell (colNum1 + c - 1) to la_valeur
end if
end repeat -- c
end tell -- row …
end repeat -- r
end tell -- Numbers …
my nettoie()
end run
--=====
on nettoie()
set my liste to {}
set my liste2 to {}
end nettoie
--=====
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 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) vendredi 30 juillet 2010 11:11:53

Jul 30, 2010 9:01 PM in response to Trevor Duck

Hi Trev. A CSV file is simply a text file with a .csv extension. All I did with your data was save it to a text file (eg. asd.txt) using TextEdit, then renamed it in Finder as a CSV file (asd.csv). If you open the txt file directly in Numbers you get each line of data in a single cell however, when you open the CSV file the data is sorted into columns based on the comma delimiter. Hope this helps.

Oct 13, 2010 12:01 AM in response to Trevor Duck

Trevor Duck wrote:
NoNo thanks for this - I tried this method before posting, but when I try to save using text edit I get no option for savig as CSV - did you save as something else and rename?


When Textedit is using the text format, we are free to save directly as .csv.

.txt is the default extension name but we may use an other one.
The main problem with the CSV format is that it is localization dependent.
When the system is using the period as decimal delimiter, the fields are separated by commas but when the decimal delimiter is comma, the fields must be separated by semi-colons.

It's often why some csv files can't be correctly opened by Numbers.

Yvan KOENIG (VALLAURIS, France) mercredi 13 octobre 2010 09:01:01

How to Parse CSV data from Web pages into Numbers - text to columns inExcel

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