-1
import json
import pandas
import requests

Convert to Pandas

I know what you're going to say, this has been asked before. But ive gone through a number of posts already and they all require importing the json file into the code already. So with this code I've been trying to import the json data through a URL, so there is no need to save any files before hand.

Is it even possible? Please help.

TwoTimer
  • 9
  • 3
  • There is a way to achieve json to csv transformation through pandas - https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html – tidakdiinginkan Jun 22 '21 at 22:29

1 Answers1

1

Pandas json_normalize can do just that. Here is an example for which you will have to modify to meet your specific needs:

df = pd.json_normalize(packages_json, record_path='results')

(I omitted the output from the DF because is it unwieldy)

jch
  • 3,600
  • 1
  • 15
  • 17
  • wow thank you, its workin! right now not all the headers (rows and columns) are being shown, but i assume there is a way to adjust that – TwoTimer Jun 22 '21 at 22:38
  • @Craig Play around with the `meta` parameter to access more fields. – jch Jun 22 '21 at 23:04