Same for invalid CSV.
There is nothing wrong with this. You can't accept all the garbage from the user.
Same for invalid CSV.
There is nothing wrong with this. You can't accept all the garbage from the user.
Yes, it does work in Excel but it's because of 40 years of various edge case fixes that you just cannot replicate in their entirety in your app.
What any other spec actually says is irrelevant. For most non-technical users, anything Excel outputs as a CSV is a CSV file (and anything you output that doesn't work with Excel is not)
So given its impossible to compete totally with Excel, how do we decide which of these edge cases are worth our time to implement?
It's not as simple as invalid input or a bad copy/paste. The user likely cannot correct the CSV.
Wait, what? Phone numbers could always include letters. Many businesses get phone numbers that include or consist of words relevant to their business, to make them memorable. And I've known people whose personal number happens to contain a word or words, so they give the letter version out because it's easy to remember. If a phone number field doesn't include simple logic to map letters into the proper numbers, that's just lazy programming.
http://www.pachd.com/free-images/technology-images/phone-dia...
There is a standard, universal mapping of letters onto numbers. This allows companies to advertise their phone number as something memorable like 1-800-CASH-4-AU and everyone knows how to dial it. People don't even need to remember the mapping of letters, because they're printed on every keypad.
And what next, do you accept exotic unicode numbers ? Letters that you casefold to something that can make to a number ?
Again, you draw the line somewhere. There is no right place for the line, it depends of your business, but there is always a line of what you accept as a user input.
Being offended won't help you on HN, and calling out people names either.
With a ZIP code in the US, it consists of 5 digits that form a unique number for a geographical area with 4 more digits that represents a sub-area within the 5 digit ZIP. But there are no instances where there can be a letter. That's a hard fact. If you put 4308A-65XK as the ZIP, the post office or delivery service will not know how to deliver the mail without trying to cross reference address with possible valid ZIP codes.
Invalid CSV is murky, because CSV is a serialization format. That is, invalid CSV may not play well with a program that accepts well-formed CSV, but a human may still be able to parse it with no problem. Returning "invalid ZIP Code" makes sense. The client would understand that letters do not belong in a ZIP Code.
If you've never had to deal with a nightmare client of that sort, hats off to you.
Why not explain to the client that you will need to put in manual or custom work to clean up the CSV or batch of CSVs and charge for the extra time writing a script or cleanup?
Literally the only time this may not apply is if you are writing a general purpose program.
Well, it all depends on the money, doesn't it?