Copying Web Tables and pasting into Numbers is not working correctly.

I know this works in excel, can it be done in Numbers? Basically, if you copy a table and paste it in numbers, you get your info going down in a straight line.

Mac Pro, MacBook, Mac Mini

Posted on Aug 10, 2007 7:16 PM

Reply
11 replies

Jan 12, 2011 7:29 AM in response to Mark Tilley

could be that IE and Safari implement HTML tables differently?


Exactly. That's why I use Camino or FireFox to copy tables from the web to spreadsheets. It's a feature/bug I've left feedback to the Safari team on several occasions, but it still exists. But, there are some sites, Discover Card is one, who have done something with their site that the data isn't in tables (tab-delimited) even though it looks like it is.

User uploaded file

Dec 22, 2010 8:49 AM in response to robster1225

robster1225 wrote:
I know this works in excel, can it be done in Numbers? Basically, if you copy a table and paste it in numbers, you get your info going down in a straight line.

I've been frustrated by this for a long time, and finally tonight I thought I'd see if I could do something about it. Turns out it's relatively simple to work around.

Safari copies the table to the clipboard as tab-delimited text, and Numbers can read tab-delimited text off the clipboard. What's the problem, then? Safari copies the text using Unix-style line breaks (ASCII character 13), while Numbers expects the text to have Mac-style line breaks (ASCII character 10). So I wrote a simple AppleScript that takes whatever's on the clipboard, and changes any Unix-style line breaks to Mac-style line breaks. Then the table can be pasted into Numbers, no problem!

Paste the following text into Script Editor, and save it as an Application. Then whenever you copy a table in Safari, just run this script application before pasting into Numbers. Hope it works for you!

set mydata to get the clipboard as text
set AppleScript's text item delimiters to {(ASCII character 13) as text}
set mylines to text items of mydata
set AppleScript's text item delimiters to {return}
set the clipboard to mylines as text
set AppleScript's text item delimiters to {""}

Dec 22, 2010 8:49 AM in response to Lowell Stewart

Lowell Stewart wrote:
Safari copies the text using Unix-style line breaks (ASCII character 13), while Numbers expects the text to have Mac-style line breaks (ASCII character 10).

Sorry, I posted (on a number of threads!) before my brain fully kicked in here. ASCII character 13 is a Mac-style line break. So my script is essentially looking for Mac-style line breaks, and replacing them with Mac-style line breaks. But it still works!! That's the weird part. I only wish I knew why, because now I look much sillier (but hopefully still helpful).

Dec 22, 2010 8:49 AM in response to Lowell Stewart

Hello

In fact the problem is simply that Safary doesn't finish its work.

After copying from the WebPage

run this huge script:

set t to the clipboard as text
set the clipboard to t

Now you may paste in a Numbers table 😉

When I examined the contents of the t variable, I discovered that rows are correctly separated by $0D aka return.

The task was finished in the process which normalizes the clipboard's contents.

Yvan KOENIG (from FRANCE mercredi 23 janvier 2008 11:29:47)

Dec 22, 2010 8:50 AM in response to KOENIG Yvan

Yeah, I suspect that Safari is simply placing multiple versions of the text on the clipboard -- at least a Rich Text version and a Plain Text version. The simple applescript -- which can be shortened to
set the clipboard to (the clipboard as text)

...simply strips out any alternate representations of the clipboard, leaving only the plain text version that is then correctly interpreted by Numbers. Woo-hoo!

Dec 22, 2010 8:50 AM in response to Lowell Stewart

Hello

Not really that as you may see in:

http://discussions.apple.com/thread.jspa?threadID=1316519&tstart=0

I apologize, the message is too long to be posted twice 😉

I already posted that to Apple so they may check why Safari is not passing the same thing than Firefox when they are assumed to do the same thing.

Not really a bug but an odd feature .

Yvan KOENIG (from FRANCE mercredi 23 janvier 2008 15:31:37)

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.

Copying Web Tables and pasting into Numbers is not working correctly.

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