Paste from CSV into Numbers

Update: Moved the code into a gist. (2013-07-05)

I was shocked to realize that Apple’s Numbers app doesn’t properly handle it if you try to paste CSV data in. It seems like such a simple oversight.

Luckily, a little searching online turned up an AppleScript script by Koenig Yvan. I made some tweaks and ended up with this:

set the clipboard to my remplace(the clipboard as text, delim, tab)

on remplace(_t, _delim, _tab)
local l set AppleScript's text item delimiters to _delim set l to text items of _t set AppleScript's text item delimiters to _tab set _t to l as text set AppleScript's text item delimiters to "" return _t end remplace

tell application "Numbers"
activate tell application "System Events" keystroke "v" using {command down} end tell end tell
```

As I did with my View Artist on AllMusic script, I use FastScripts to setup a keyboard shortcut like ⌘⇧V in Numbers.

Now we’re living the dream.