(After five hours of narrowing it down from a real-world shop data Import, I seem to have this rather unlikely bug - any ideas, anyone?) -
I start a brand-new Shopify account, and make a new empty shop.
I make this CSV file in a text editor:
Handle,Title,Body (HTML) nfl-tshirt,NFL Tshirt,"<a href=""https://www.nfl.com"">NFL</a> related Tshirt"
But when I import it, I get this well-known error message:
There was an error importing your CSV file. After you fix the error, try importing the CSV file again.
Only CSV files are supported at this time. Verify the file and try again.
However, the bug only seems to happen if the '=' in my '<a href=>' (a HTML anchor) is in the first 128 bytes of the CSV file(!!!):
– If you try this with other HTML codes, like "<p>" or "<b>", they're fine early, so it's not "any angle brackets/any HTML"
– It is nothing to do with the "double doublequotes", as they work fine early outside of an "<a>"
– It is definitely to do with this '<a>' being HTML, because if you replace all four angle brackets in the above CSV file with the character "X", say, it will import fine (albeit as weird text of course!)
– If you do anything at all to move this "<a href=...>" a tiny bit further down the file, past the 128 character position, the file will Import correctly!
For example, here are three files where I have added (1) a dummy column title, (2) a new first line of data, or (3) more text at the start of the offending "Body(HTML)" field. All three Import correctly!
Handle,Title,Body (HTML),ADummyfieldnameADummyfieldnameADummyfieldnameADummyfieldnameADummyfieldname nfl-tshirt,NFL Tshirt,"<a href=""https://www.nfl.com"">NFL</a> related Tshirt",
Handle,Title,Body (HTML) another-tshirt,Another Tshirt,There is no link as this is just a dummy Tshirt entry nfl-tshirt,NFL Tshirt,"<a href=""https://www.nfl.com"">NFL</a> related Tshirt"
Handle,Title,Body (HTML) nfl-tshirt,NFL Tshirt,"DummyText DummyText DummyText DummyText DummyText DummyText DummyText DummyText <a href=""https://www.nfl.com"">NFL</a> related Tshirt"
BTW, I did test down to the individual character position, and
['=' at char 128] fails
['=' at char 129] imports OK
Of course, there might be other HTML codes that have a similar issue – I can't test all of them.
[PS: Tested for Plain CSV and for UTF-8-BOM CSV (if you are using a binary editor, a UTF-8-BOM CSV file starts with three weird-looking bytes which are a special code and not part of your data, and you should ignore those three if counting to 128).]
And I know this might seem a slightly rare situation, but when it does happen it's a seemingly undiagnosable, client-losing disaster.