Yep, I had a " in my passphrase. I have now changed that and started the import again. However, I now get:
Error: Please enter the wallet passphrase with walletpassphrase first. (code -13)
That's talking about your CLAM wallet. In order to import private keys into your CLAM wallet from the BTC wallet, the CLAM wallet needs to be unlocked. It's the same as when you try to import a private key into any encrypted wallet - you need to unlock the wallet first:
$ bitcoin-cli importprivkey 5JyEXcta7Z3QUo9R4hDkEocK3mTChquRwKbsdXPoDJ27fN1sD6U
error: {"code":-13,"message":"Error: Please enter the wallet passphrase with walletpassphrase first."}
$
So in the QT interface, click 'Console' at the bottom of the left-hand pane, then type:
walletpassphrase fred 3600
where 'fred' is the CLAM wallet's passphrase, and 3600 is the number of seconds to unlock it for.
Then you'll be able to import your BTC wallet.
Edit: I experimented with the 'Console' window to see how to type passphrases with single and double quotes in them. It turns out you can quote single quotes using double quotes, and can quote double quotes using single quotes. You can also backslash-escape both types of quotes, but backslash escaping doesn't work inside single quotes. Probably the easiest way of doing it is to put a backslash before any single quote, double quote, and space in the passphrase:
My passphrase was:
a " b ' c
ie. 9 characters: a, space, double-quote, space, b, space, single-quote, space, c
I was able to unlock the wallet by typing any of these 3 commands:
walletpassphrase a\ \"\ b\ \'\ c 3600 (backslash-escaping each space and quote separately)
walletpassphrase 'a " b'" ' c" 3600 (single-quoting the double quote, and double-quoting the single quote)
walletpassphrase "a \" b ' c" 3600 (double-quoting the whole thing, and backslash-escaping the double-quote)
Yes, I'm aware that it is retarded that you need to go to these lengths. But I just noticed there's a menu entry: Misc->UnlockWallet, which lets you simply type the passphrase to unlock your wallet. It seems the default is to unlock for staking only, so you probably need to uncheck that option. And I don't see a way of specifying how long to unlock for, so you'll want to Misc->LockWallet when you're done importing.