It's 2019 and our coreutils still don't have a way to output structured, parseable data.

I'm so fed up with "stringly-typed" shell programming πŸ˜’

@fribbledom really? From my experience, most of them output something very close to CSV/DSV, which you can easily parse with awk.

@Wolf480pl

Ok, I rephrase:

"...a way to output _sanely_ structured, parseable data..."

πŸ˜‰

@fribbledom
>suggesting awk is insane
>suggesting JavaScript Object Notation is saner

You've lost the Path of Unix. But it's not too late. Repent!

@Wolf480pl

I haven't suggested JSON just yet, but yes I'd much rather work with JSON than CSV. Who wouldn't?

@fribbledom @Wolf480pl

CSV is a shit show. Especially when dealing with a lot of data and odd data. Definitely use JSON or yaml, or something similar if you can.
Follow

@bort @fribbledom
if your data isn't nested, I don't see any advantage to JSON.

AFAIK JSON and CSV have very similar quoting/escaping rules. And DSV is even simpler than CSV, because there's no quoting, you just pick a separator that doesn't appear in the data. Most of the time, tab is good enough.

@Wolf480pl @fribbledom

It really depends on what the data itself is. A LOT of CSV parsers crap out on stuff, especially if you are using comma's for delimiting. However, it looks like it's output from iproute or something, so I don't think any parser will have issues with that.
@Wolf480pl @fribbledom

And I had MANY problems with tab delimited too. I used to have to import CSV files, mostly not using standard delimiters. The e-discovery company I worked for had to deal with huge CSV files to get legal formatted stuff into the system. It was a nightmare. CSV is fine for simple use cases, but when dealing with very large files, that won't necessarily have consistent text, especially unicode that was converted badly, other formats tend to work better.

@bort @fribbledom
Still souds like more of a problem with buggy parsers than the format itself. Have you tried using awk?

@bort @fribbledom
or, if you're writing code, sth like
str.split('\t') ?

@Wolf480pl @fribbledom

But if the data has tabs itself in it, that can be a problem. That's why it really depends on what kind of data is there to begin with whether tab delimited is good or not. If it's something like output from a tool, usually that's fine. It's when you have to deal with raw data not output in a very specific way that you have issues. I never even had a clue it was an issue until having to deal with that stuff for like 5 years. Thankfully, linux and such has a much easier time with that kinda data, it's mostly windows libraries that crap the bed. Go unix!
@Wolf480pl @fribbledom

I've likely been using unix longer than you've been alive, so yes :)

But yes, you are πŸ’― correct, all the problems were because of shitty parsers, especially under windows. Those were the cases where I had to write my own to get the data in.

@Wolf480pl @bort @fribbledom simple: comments. When it gets complex I actually use yq which hammers it into JSON and then uses jq to get the info I need and optionally converts it back to yaml.

Sign in to participate in the conversation
niu.moe

Welcome to your niu world ! We are a cute and loving international community οΌ―(≧▽≦)οΌ― !