FIX
I had this problem upwards of 7 or 8 times, and I fixed it by replacing the defective cable. The more times I did this, the shorter the fix held for. I have now found a workaround by using a hard drive caddy. They are available of amazon for less than £10. You remove the optical drive (for CD/DVDs) and put the caddy in its place. The hard drive is then connected to the computer via different route, bypassing the defective data cable. It does mean you no longer have an optical drive, but that's a small price to pay to have a functional computer!
Caddy: https://www.amazon.co.uk/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=macbook+pro+hard+drive+caddy&sprefix=macbook+pro+hardd%2Caps%2C196&crid=1LO0SSSEKI47V