Jan-28-2023, 09:01 PM
the following will read all files into separate dataframes.
You will have to store each in a list (or whatever else you wish)
You will have to store each in a list (or whatever else you wish)
from pathlib import Path import pandas as pd # import json sourcedir = Path('/Users/macbook/Desktop/Saveddata') filelist = [x for x in sourcedir.iterdir() if x.is_file() and x.suffix == '.json.'] for file in filelist: df = pd.pandas.read_json(file) # now do what you wish with the dataframe as next file will overwrite df # to read directly into a dictionary instead use: # with file.open() as jfile: # jdata = json.load(jfile)