Python Forum
Load multiple Jason data in one Data Frame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load multiple Jason data in one Data Frame
#1
Hi All

I need your guidance :

I have three Jason files which in my local drive which need to be loaded in one data frame so that I can do the further exploratory data analysis. I have written a code but this only loads last file in the data frame . Kindly please find the below code for reference.

I have also attached the Json files and notebook code screen shot.

import json
import pandas as pd
import os

path_to_json ='C://JsonFiles//'

def file_path(path_to_json):
    json_files = [path_to_json + pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')]
    return  json_files

for jf in file_path(path_to_json):
    with open(jf,'r') as f:
        data = json.loads(f.read())
        # Flatten data
        df_nested_list = pd.json_normalize( data, record_path =['attributes'], meta=['ORDERNUMBER', 'PRODUCTCODE'])
        

df_nested_list  

Attached Files

Thumbnail(s)
   

.zip   JsonFiles.zip (Size: 38.4 KB / Downloads: 102)
Reply


Messages In This Thread
Load multiple Jason data in one Data Frame - by vijays3 - Aug-12-2022, 05:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 452 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  Load data in Oracle muzokh 0 273 Mar-08-2024, 11:19 PM
Last Post: muzokh
  Using pyodbc&pandas to load a Table data to df tester_V 3 856 Sep-09-2023, 08:55 PM
Last Post: tester_V
  how do you style data frame that has empty rows. gsaray101 0 544 Sep-08-2023, 05:20 PM
Last Post: gsaray101
  googletrans library to translate text language for using data frame is not running gcozba2023 0 1,256 Mar-06-2023, 09:50 AM
Last Post: gcozba2023
  Write sql data or CSV Data into parquet file mg24 2 2,478 Sep-26-2022, 08:21 AM
Last Post: ibreeden
  conditionals based on data frame mbrown009 1 920 Aug-12-2022, 08:18 AM
Last Post: Larz60+
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 2,704 Jul-25-2022, 03:19 PM
Last Post: deanhystad
  Merging two Data Frame on a special case piku9290dgp 0 1,100 Mar-02-2022, 10:43 AM
Last Post: piku9290dgp
  OCR-Python from Multi TIFF to HOCR getting only Data from 1st Page of multiple TIFF JOE 0 2,184 Feb-18-2022, 03:18 PM
Last Post: JOE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020