Can someone help me out with the following:
I have a folder that contains levels of sub folders, which each contain several json files. I have been using the following code to extract them all and join them into a dataframe:
PATH = ("C:/Users/77901898/Documents/.../11 - Trial run")
EXT = ("*.json")
json_files = []
for path, subdir, files in os.walk(PATH):
for file in glob(os.path.join(path, EXT)):
json_files.append(file)
df = pd.concat([pd.read_json (file) for file in json_files], ignore_index = True)
But I am getting the following error: "If using all scalar values, you must pass an index"
I have also tried the implementation from this question: How to read multiple json files into pandas dataframe? but it throws up "ValueError: No objects to concatenate"
glob(os.path.join(path, EXT))try to print the value offile. According to os.walk documentation "To get a full path (which begins with top) to a file or directory in dirpath, do os.path.join(dirpath, name)." IN your case, the variable names would be path and files docs.python.org/3/library/os.html#os.walk