Apr-02-2025, 05:49 PM
hi all,
I just wrote my hello world program in Python and I need some guidance for reading a somewhat complex json file for uploading it to a Sql Server table.
I installed pandas and I see it has a input/output command pandas.json_normalize()
I see this example:
Basically, I start with this multiple level nested json and I build this file where various levels become level1.level2.level3... columns in a table and the values are in rows.
Please help me take the first step: how do I get the data argument from my initial json file myFile.json?
pandas.json_normalize(data, record_path=None, meta=None, meta_prefix=None, record_prefix=None, errors='raise', sep='.', max_level=None)
Thanks,
elsvieta
I just wrote my hello world program in Python and I need some guidance for reading a somewhat complex json file for uploading it to a Sql Server table.
I installed pandas and I see it has a input/output command pandas.json_normalize()
I see this example:
Output:>>> data = [
... {
... "id": 1,
... "name": "Cole Volk",
... "fitness": {"height": 130, "weight": 60},
... },
... {"name": "Mark Reg", "fitness": {"height": 130, "weight": 60}},
... {
... "id": 2,
... "name": "Faye Raker",
... "fitness": {"height": 130, "weight": 60},
... },
... ]
>>> pd.json_normalize(data, max_level=1)
id name fitness.height fitness.weight
0 1.0 Cole Volk 130 60
1 NaN Mark Reg 130 60
2 2.0 Faye Raker 130 60
which is exactly what I need as an output.Basically, I start with this multiple level nested json and I build this file where various levels become level1.level2.level3... columns in a table and the values are in rows.
Please help me take the first step: how do I get the data argument from my initial json file myFile.json?
pandas.json_normalize(data, record_path=None, meta=None, meta_prefix=None, record_prefix=None, errors='raise', sep='.', max_level=None)
Thanks,
elsvieta