If you are buying through an agent and/or using a solicitor they should be able to sort this out as part of their service.
May cost a bit if meters have been removed but last bought 2 yrs ago, repo from bank, and Iberdrola reconnected with no problem but water company refused to reconnect without original or second cert of habitation to make out new contract. To get around this we paid off the outstanding water bills ( approx 300 Euros) and then arranged to pay by direct debit from our bank account.
Our agent sorted it all out as part of his service.
I really must get around to changing the contract into our name one of these days.
Jean