How in Python to partially write JSON to CSV?

I need to JSON and write it in a file of only two fields. he don like {"a" : 1, "b" : 2, "c" : 3}. I have, for example, only a and C.

You can first make cuts in the JSON after receiving it, I understood it as, but since this operation will be performed repeatedly, it is likely that the method is very resource-intensive srvneniyu for partial recording, if there is one.

Get it:

url = "any.address"

data = requests.get(url=url)

binary = data.content

output = json.loads(binary)
June 14th 19 at 19:14
3 answers
June 14th 19 at 19:16
And what does not fit?
a = output["a"]
c = output["c"]
June 14th 19 at 19:18
You got in the output dictionary (dict) with values.

If you know what to remove (and it always is) and its not a lot, just del(output["a"]) ... and keep trimmed output.

If you have to remove and keep just anything, it is easier to pull the desired a = output["a"] and to keep it.

If you need multiple items to remove/pull out, but with the above methods to do in a loop.

For example:
for item in ('a', 'b'):

# picks
result = dict()
for item in ('a', 'b'):
 result[item] = output[item]
June 14th 19 at 19:20
A practical example. Sorry that the picture - copy the inconvenient59dcd5d04c079796802083.png

Find more questions by tags CSVJSONParsingPython