in reply to Re^8: Complex file manipulation challenge
in thread Complex file manipulation challenge

Thank you very much for this great in-depth digression about IT history.

But i don't give up so easy. Remember: It is/we have:

Karls-Mac-mini:~ karl$ date Sa 17 Aug 2019 19:44:17 CEST
"...legacy systems still work..."

That is O.K. But i'm still convinced that JSON is the way to go now. On the other hand decades ago i "endorsed" XML in the companies i was with. Yet another "reach into the toilet". Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Replies are listed 'Best First'.
Re^10: Complex file manipulation challenge
by afoken (Chancellor) on Aug 17, 2019 at 20:24 UTC
    That is O.K. But i'm still convinced that JSON is the way to go now. On the other hand decades ago i "endorsed" XML in the companies i was with. Yet another "reach into the toilet".

    Yeah, XML sucks. There is absolutely no way to encode the NUL character ("\0"), it is simply illegal. You have to resort to base64 or some custom escaping. It has lots of redundancy, whitespace handling can drive you insane (CDATA, PCDATA ...), and a few lines of XML can kill your parser (Billion laughs attack). But at least, you can have comments.

    JSON does not allow comments. And no, whatever garbage JSON::XS accepts with '#' followed by junk followed by a CR or LF is not JSON. JSON is defined as a subset of Javascript. Why on earth would one resort to Unix shell scripts for a comment syntax? Javascript has well-defined comments, so the most natural extension to JSON would be Javascript comments, not shell comments. (See also Re^3: Freezing a regular expression qr().)


    Now, JSON instead of CSV. Feel free to propagate JSON, especially as a replacement for CSV. I'm fine with that. You should perhaps start by sending in some patches for various projects:

    Gnuplot reads data from CSV files, but can't read JSON. It's a great tool for debugging the differences between real-world physics and the concept's idea of physics. Have your embedded system spit out some numbers of what it senses from the real world, feed them through Gnuplot, and compare the graphs with what is drawn in the concept.

    LibreOffice Calc also lacks JSON import, and probably also JSON export. Calc can be used instead of Gnuplot, or to preprocess data for Gnuplot, when debugging physics. Most likely, the same is true for OpenOffice.

    When you're done there, complain at Microsoft that Excel does not support JSON like Calc will then do.

    Some databases already support JSON as a data type (i.e. content of a table cell). But can they dump out views, tables, query results as JSON instead of CSV? And can they read JSON back like they can read back CSV? Start with patching PostgreSQL and MariaDB / MySQL. Both are very widely used, open source, and both lack JSON import and JSON export.

    When you're done there, start nagging Microsoft (SQL Server, Access), Oracle, and IBM (DB/2).

    What's the use case for databases? Well, DB admins in general don't want third parties to access their precious databases. Even if they don't look like Gollum, my precious. During my professional life as a software developer, I have never met a DB admin that simply allowed access to his precious. Don't even think about write access, even highly restricted read access either takes ages or requires escalation to management. If you are lucky, you can get a CSV dump every day, every hour, or on change of relevant data. Yes, this is far from optimal, but often sufficient.

    Oh, and do you have implementations of cut, paste, join, sort, and uniq that work on JSON. No? Send patches ...

    Don't forget that /etc/passwd, /etc/groups, /etc/shadow, /etc/gshadow are also CSV files. Send patches to make them JSON. It's 2019, after all, Unix is nearly half a century old now, time to get rid of old habits. Perhaps start with the systemd people, they don't understand the basics of Unix at all, so they should be easy to persuade.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Well, it sometimes seems to be hard to write a short posting. ;-)

      My point is that CSV exists and is successful because there are tons of code writing and reading CSV, and they won't go away any time soon.

      Another advantage of CSV is that the tabular data is also represented as a table. Each table line is a line in the file, and columns are separated by a character. (That's the C and S in CSV, duh!) And while you could format JSON (or XML) in the same way, you don't have to. That breaks tools like cut, paste, join, sort, uniq, that all assume tabular data being layed out as explained.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        Yes sure. Of course you are right. I surrender now. And i didn't want to question basic Unix principles. But sometimes i wished/or life would have been a bit easier if some Unix tools would have had a --json or --xml option. Perl has enough devices to replace the classical Unix commands you mention. And yes: you can have comments in JSON files. But as always our beloved brother choroba found the hair in the soup. And the "solution" provided ibidem isn't really satisfying. Best regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

        perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help