News for hackers. Stuff that matters.
Re:TSV Utilities: Command line tools for large, tabular data... by cbsmith on Saturday August 31, 2019 @08:10PM (#20849644)
It makes me cry how much time has been invested in formats like CSV's, TSV's, etc. ASCII (and UTF-8) has characters reserved for column, row, and even group separation. Just use them and save a lot of pain.
Re:TSV Utilities: Command line tools for large, tabular data... by dev_dull on Saturday August 31, 2019 @08:59PM (#20849844)
We’ve discussed this at length and I’m squarely in the DO NOT camp. The drawbacks of using non-readable meta characters exceeds the benefits:

1. TSV can be read and imported by almost everything.

2. People can add and adjust TSV files from any editor.

3. What’s the way to insert meta characters again In VIM? And now nano? Argh I’ll just try and copy and paste it. Ugh that doesn’t work.

Just use CSV/TSV folks. Anything more complicated and reach for a better serialization format (json, yaml) and not a better delimiter.

Re:TSV Utilities: Command line tools for large, tabular data... by cbsmith on Saturday August 31, 2019 @09:04PM (#20849861)
2. More accurately, people can screw up TSV files from any editor. Have you not seen embedded spaces used instead of tabs and totally mess everyone up?
Re:TSV Utilities: Command line tools for large, tabular data... by cbsmith on Saturday August 31, 2019 @09:01PM (#20849850)
Like a lot of things, #1 is only partly true, particularly if you have embedded tabs.

The number of times I've had to deal with parsing errors because of embedded carriage returns, commas, tabs, etc., sometimes costing millions of dollars is just... upsetting.

It's like JSON... we say everything can parse it, but really what we've got is some approximation that will come back to haunt us... and once you've done all the work to make sure everything is precise and correct, you'd really have saved time if you'd just used the tools we already had in the first place.

Re:TSV Utilities: Command line tools for large, tabular data... by mruts on Saturday August 31, 2019 @09:27PM (#20849963)
Dealing with tabs and carriage returns has sometimes cost you millions of dollars? If so, that sounds like a great story and I would love to hear it!
Re:TSV Utilities: Command line tools for large, tabular data... by jlgaddis on Saturday August 31, 2019 @09:58PM (#20850078)
Especially if (as it sounds) it's happened more than once!
Re:TSV Utilities: Command line tools for large, tabular data... by Annatar on Sunday September 01, 2019 @04:56AM (#20851242)
Both JSON and YAML are very difficult to construct parsers for.

To make matters worse, both formats are full of pitfalls:

http://seriot.ch/parsing_json.php https://arp242.net/yaml-config.html

using either of these, in my opinion, is extremely misguided.

Re:TSV Utilities: Command line tools for large, tabular data... by chucksmash on Thursday September 05, 2019 @08:33AM (#20885968)
Can't find a source for it now, but one of the design goals of JSON iirc was that it should be easy to parse.

You should have a go at writing a JSON parser to convince yourself it isn't hard. Can manually lex it in less than 150 lines of Python.

Re:TSV Utilities: Command line tools for large, tabular data... by dev_dull on Sunday September 01, 2019 @10:48AM (#20852556)
The flip side to that is that json and yaml parsers exist in every language, and would be more than capable of replacing any logic you’d find in a CSV.
Re:TSV Utilities: Command line tools for large, tabular data... by Annatar on Monday September 02, 2019 @02:35AM (#20857174)
CSV's are a data structure. They do not contain any logic.
Re:TSV Utilities: Command line tools for large, tabular data... by tinus_hn on Tuesday September 03, 2019 @06:26PM (#20871886)
Just use these formats if you want to be stuck in the last century when internationalization was that odd thing you could easily afford to ignore. Otherwise, use a real format.
Re:TSV Utilities: Command line tools for large, tabular data... by cbsmith on Saturday August 31, 2019 @09:05PM (#20849864)
3. If you don't know how to use your editor, maybe you should learn. If your editor can't insert even all the characters in basic ASCII, it's not an editor.
Re:TSV Utilities: Command line tools for large, tabular data... by dev_dull on Saturday August 31, 2019 @09:41PM (#20850020)
Go ahead and give every engineer who comes across your meta-delimited file a little rundown on how it works. "Can you show me how to import it into google sheets?" "I need to email it to someone, can you show me how to change it?" "My IDE says I need a plugin to read it? Do you know anything about that? Can you help me set it up?"

They'll all agree how clever and useful the meta characters are of course, but only after you've given them your time in learning about it. No thanks no thanks no thanks. For me I'd rather deal with a little bit of serialization headache then a support headache.

Re:TSV Utilities: Command line tools for large, tabular data... by cbsmith on Saturday August 31, 2019 @11:56PM (#20850417)
...and this is why we can't have nice things.
Re:TSV Utilities: Command line tools for large, tabular data... by jefftk on Saturday August 31, 2019 @08:21PM (#20849695)
While that might have been a good idea if we'd started a while ago, at this point CSV/TSV are so much more established that using commas or tabs doesn't actually save pain.
Re:TSV Utilities: Command line tools for large, tabular data... by zachrose on Saturday August 31, 2019 @08:29PM (#20849723)
But wouldn’t you have to account for the possibility that those separators exist in the content your working with, putting you back at square one in terms of escaping?
Re:TSV Utilities: Command line tools for large, tabular data... by kec on Saturday August 31, 2019 @08:35PM (#20849743)
That's entirely the point: 0x1C and 0x1E should never actually appear in "normal" text unless someone has explicitly put them there, which is not necessarily true of , \t or \n.
Re:TSV Utilities: Command line tools for large, tabular data... by xashor on Saturday August 31, 2019 @09:05PM (#20849863)
We took the wrong path quite some time ago. Most of the POSIX utils like sort, cut, grep only support \n (or sometimes \0) as row separator.
Re:TSV Utilities: Command line tools for large, tabular data... by jlgaddis on Saturday August 31, 2019 @09:59PM (#20850083)
Are you aware of $IFS?
Re:TSV Utilities: Command line tools for large, tabular data... by xashor on Sunday September 01, 2019 @03:03AM (#20850912)
I think $IFS is only used by the shell (with read and expansions), not by e.g. sort. It is so at least on my system.
Re:TSV Utilities: Command line tools for large, tabular data... by dagenix on Sunday September 01, 2019 @02:24AM (#20850789)
But, there is nothing to stop your values from containing these characters. So, you still have to escape your input. And once you've done that, you might as well just use csv / tsv.
Re:TSV Utilities: Command line tools for large, tabular data... by cbsmith on Wednesday September 04, 2019 @03:30AM (#20874818)
Actually, the whole point of those characters is that they cannot be used in values.
Re:TSV Utilities: Command line tools for large, tabular data... by perl4ever on Sunday September 01, 2019 @01:37AM (#20850653)
For some reason, in some circles, it seems to be semi standard to use þ (0xFE aka thorn) as the delimiter and a paragraph symbol (0x14 aka DC4 aka ^T) as the separator. The latter is not to be confused with 0xB6.

Anyway, these character are presumably not going to occur in ordinary text.

Re:TSV Utilities: Command line tools for large, tabular data... by PeterisP on Sunday September 01, 2019 @04:33AM (#20851173)
All of "upper ascii half" can occur in ordinary text in "pre-Unicode" encodings.

0xFE is a good example - you may get a customer or employee from Iceland with that character in their name (e.g. https://en.wikipedia.org/wiki/Haf%C3%BE%C3%B3r_J%C3%BAl%C3%A...), or data in cyrillic cp1251 or koi8-r enconding where 0xFE also represents characters that you'll encounter in surnames, etc.

Re:TSV Utilities: Command line tools for large, tabular data... by perl4ever on Sunday September 01, 2019 @09:45PM (#20856191)
It would be escaped in that case.
Re:TSV Utilities: Command line tools for large, tabular data... by mdellavo on Saturday August 31, 2019 @08:34PM (#20849741)
using csv and tools like grep and join is very fast for large datasets
Re:TSV Utilities: Command line tools for large, tabular data... by lgas on Saturday August 31, 2019 @08:57PM (#20849833)
Using the reserved separator characters wouldn't change that.
Re:TSV Utilities: Command line tools for large, tabular data... by perl4ever on Sunday September 01, 2019 @01:26AM (#20850625)
I always used cut, sort, and uniq a lot too.
Re:TSV Utilities: Command line tools for large, tabular data... by jstimpfle on Sunday September 01, 2019 @06:12AM (#20851468)
How do you do (for example) column names or types with ASCII only?

How do you extend ASCII?

Re:TSV Utilities: Command line tools for large, tabular data... by kps on Sunday September 01, 2019 @04:38PM (#20854747)
ESC is the ASCII character for code extension.

ISO 2022 aka ECMA-35¹ standardizes how to use it in general, but the only thing that really caught on is a subset of the terminal control extensions (ISO 6429 aka ECMA-48² aka ‘ANSI’). In the hypothetical alternate universe where people use ASCII-based structured data, ISO 2022 would have standard sequences for such metadata.

If you were rolling your own today, you'd probably wrap the metadata in Application Program Command (ESC _ … ESC \) or Start Of String (ESC X … ESC \) or one of the private-use sequences. ¹ https://www.ecma-international.org/publications/standards/Ec...

² https://www.ecma-international.org/publications/standards/Ec...