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

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". ;-)
  • Comment on Re^11: Complex file manipulation challenge

Replies are listed 'Best First'.
Re^12: Complex file manipulation challenge
by karlgoethebier (Abbot) on Aug 18, 2019 at 14:31 UTC

    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

      I only agree with you to the extend of programs/applications not having options for different output.

      OTOH I so much wish that all those applications that generate (erroneous) XML should have an option to generate (correct) CSV. I *really* hate the overhead of XML tags, esp when not needed. And XML is relatively easy to get it wrong (but so are all other formats).

      The *HUGE* advantage of CSV of any other format it that - for 2 dimentional tables (just rows and columns) - the overhead of the "Labels" (headers) is minimal. With (valid) XML, every field in the matrix needs to be labeled causing a huge unneeded overhead in storage. If I do a database table export of 23 million rows, I am quite sure CSV is about 5% of the size of what XML would be. This matters a lot in parsing speed (and generating speed FWIW).

      The big advantage of JSON is that you can generate streams of data, as most whitespace is irrelevant, and that json_pp is able to prettify it if needed.


      Enjoy, Have FUN! H.Merijn
      % ps -Upostfix PID TT STAT TIME COMMAND 1114 - I 0:08.52 qmgr -l -t fifo -u 57382 - I 0:00.04 pickup -l -t fifo -u 82762 - I 0:01.28 tlsmgr -l -t unix -u % ps -Upostfix --libxo=json {"process-information": {"process": [{"pid":"1114","terminal-name" +:"- ","state":"I","cpu-time":"0:08.52","command":"qmgr -l -t fifo -u" +}, {"pid":"57382","terminal-name":"- ","state":"I","cpu-time":"0:00.0 +4","command":"pickup -l -t fifo -u"}, {"pid":"82762","terminal-name": +"- ","state":"I","cpu-time":"0:01.28","command":"tlsmgr -l -t unix -u +"}]} }

        Yes, i know less or more.

        But look:

        Karls-Mac-mini:~ karl$ ps -Upostfix --libxo=json ps: illegal option -- - usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]] [-g grp[,grp...]] [-u [uid,uid...]] [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]] ps [-L]

        Different implementation i guess. That's a part of the problem.

        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