Reputation: 909
I have a folder that contains many JSON files. I want to write Python code that scans all files, reads them, and merges them into a single list object.
I tried the following.
mypath = 'C:/Users/data'
files = ['f1.josn', 'f2.josn', ..., 'f20.josn']
output_list = []
for file in files:
with open(mypath+'/'+file, encoding='utf-8') as infile:
output_list.append(json.load(infile))
I got a traceback after running the above code:
JSONDecodeError: Invalid control character at: line 1002 column 99 (char 38611)
Upvotes: 0
Views: 37