× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Thu, Aug 1, 2024 at 3:45 PM Buck Calabro <kc2hiz@xxxxxxxxx> wrote:

As a strictly amateur Python-er, I would think that
requests - for the web side; retrieving the JSON and delivering the csv
JSON - to convert the JSON to a dict
csv - to consume the dict and write rows to the csv file

All sound choices. The latter two are in the Python standard library.

How would those be as search terms for someone interested in a Python
solution? I worry that I have ancient memories and thus am totally
missing out on a modern, Pythonic way to do this.

I do not keep up with Python developments as avidly as I used to, but
I am confident there isn't much, if any, more modern way that is an
improvement over what you were thinking.

In any case, the search terms are simply the words of the question
you'd like answered. For example,

- how do i read json data in python
- how do i write a csv file in python

The SQL solution is an interesting proposal. Our SQL can do HTTP stuff,
decode the JSON, and write stream files. I'd think that making the csv
columns wouldn't be too hard, but I expect this is more nitty-gritty
than Python would be.

After taking a very quick look at the SQL reference, I would agree. I
kind of expected explicit CSV functionality, but I can't find it.

It feels like an ancient and long-solved problem to me, but I am sure
there are still plenty of people, particularly in the IBM midrange
world, writing their own CSV output procedures from scratch even
today, and falling into the same traps that countless others have
for... going on decades now. But Python's CSV module has been there
forever, and takes care of all the sticky situations like "my data
contains literal commas and quotes, how do I deal with that?".

For what it's worth, CPYTOIMPF has gotten a lot better over the years.
Circa V5R2 it was still doing an amazingly bad job of CSV, to the
point where it's no wonder people were rolling their own. Now, I'd say
it's a serviceable option for a large percentage of cases.

I want to be clear about one thing that I find is a significant
advantage in Python (and I expect pretty good in SQL as well), even
more so than sophisticated handling of CSV corner cases: Python makes
you deal with encodings in an explicit way. It's painful when I see
IBM midrangers futzing with CCSIDs in various places (files, fields,
programs, jobs, user profiles, etc.) in a desperate attempt to coax
IBM's implicit and comprehensive CCSID machinery to achieve what they
want. And these midrangers often do not instinctively know where and
how to look at raw hex codes, because when the CCSID machinery is
working smoothly, nothing could be easier or more transparent. In
Python, you control where and which encoding(s) to use, and if you
happen to get one wrong, you fix it at the point of failure (which is
generally evident from the error message) and move on.

John Y.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.