5 ms·
These look easy, but I don’t think they always are. Think about CSV for example. Looks simple to create and parse. In reality these simple implementations will
by jpalomaki 6y ago
These look easy, but I don’t think they always are.
Think about CSV for example. Looks simple to create and parse. In reality these simple implementations will give you lot of headache when they don’t handle edge cases (escaping, linefeeds etc).
- u801e 6y agoIf they only used the ASCII record separator instead of a comma.
- edflsafoiewq 6y agoThen you couldn't type it in a text editor.
- u801e 6y agoI guess it depends on a text editor. Mapping a key to insert that character is one possible solution.
- jeffbee 6y agoStandard unix-style input accepts ctrl-^ as ASCII RS and ctrl-_ as ASCII US. If you want your terminal to accept an ASCII US literally — so that you can use it as the -t argument to sort, for example — you would use ctrl-v ctrl-_ to give it the literal character. $ hd ^^^_ 00000000 1e 1f 0a 00000003 $ sort -t "^_" -k 2,2n a^_42 z^_5 n^_7 z5 n7 a42
- leejoramo 6y agoI always preferred tabs to CVS, but how I wish our industry had made use of the ASCII record separator character. How many hours would I and my teams have saved in the last 20 years?
- SahAssar 6y agoYou would still need to be able to handle escaping, right? Otherwise you couldn't have a string with a record separator within a CSV column.
- nightcracker 6y agoThe problem with CSV isn't that it's text based, the problem is that "CSV" isn't a file format with an authoritative description.
- jandrese 6y agoThere is a RFC (4180) for CSV, but the truth of the matter is that there are thousands of parsers written to whatever spec the author thought up. In the real world the entire spec is contained in its three word name. In the end I think the simplicity was also a weakness. Because the spec is so minimal a programmer goes "Oh, I'll just write my own, no problem", where a more complex protocol would have necessitated finding some exisiting library instead. Whatever the author of that library did would become the defacto standard and there would be less incompatibility between files.
- sgtnoodle 6y agoThat reminds me of the time I needed to parse some XML and ended up writing my own parser...