[lug] Convert JSON to CSV - adding header line

Davide Del Vento davide.del.vento at gmail.com
Sun Jan 17 07:00:19 MST 2021


On Sat, Jan 16, 2021 at 10:17 AM Jed S. Baer <blug at jbaer.cotse.net> wrote:

> On Fri, 15 Jan 2021 18:56:38 -0700
> Davide Del Vento wrote:
>
> > I think for things like this (any text parsing and reformatting) is
> better
> > to use a (well written and well documented) python script.
>
> I considered that, and looked at some examples - seemed pretty easy,
> overall. But I'm not all that hopeful of Python script portability these
> days - perhaps in a few years things will improve. And I have no idea what
> a Python environment looks like on Win10.
>

I don't have that idea either, but python does allow you to write things
totally generically e.g. with programmatic file separator (rather than "/"
which I think will break on Windows). If you use no external dependencies,
you need to pay attention only (besides not hardcoding not portable details
such as "/") to what version of python you are writing for. The docs are
pretty good at that (even though not as good as java's). For example, it
says that if you want to use
https://docs.python.org/3.2/library/os.path.html#os.path.samefile you need
to use at least python 3.2 on Windows. You can write for the oldest version
you feel comfortable for and do a check version first thing, politilely
exiting with "python v xxx or newer needed" if not satisfied.


> Conversely, I have a more confident expectation that the jq executable in
> other environments will digest a filter recipe and produce the expected
> output.
>

Maybe. But then you need to interact with the shell, as the output
redirection suggested by David implies. So now you need to support multiple
shells. Perhaps not hard for this case, but something I banged my head
enough on, that I prefer to avoid it as much as possible.

Best of luck!


>
> --
> All operating systems suck, but Linux just sucks less
>  - Linus Torvalds
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20210117/9fcbca21/attachment.html>


More information about the LUG mailing list