Very simple question! I want to merge multiple JSON files and the
Check this out:
f1data = f2data = f3data = f4data = f5data = f6data = ""
with open('1.json') as f1:
f1data = f1.read()
with open('2.json') as f2:
f2data = f2.read()
with open('3.json') as f3:
f3data = f3.read()
with open('4.json') as f4:
f4data = f4.read()
with open('5.json') as f5:
f5data = f5.read()
with open('6.json') as f6:
f6data = f6.read()
f1data += "\n"
f1data += f2data += f3data += f4data += f5data += f6data
with open ('merged.json', 'a') as f3:
f3.write(f1data)
And the output should be like this:
[
{
"id": "1",
"name": "John",
},
{
"id": "2",
"name": "Tom",
}
]
The problem is that Visual Code Studio brings up a red line under: f1data += f2data += f3data += f4data += f5data += f6data
I have no idea why! And the code can't run! there is no error so i can troubleshoot..Any advice?