how to dynamically insert keys into an existing python dictionary, input is the .json file and the output in a .csv file.

this is the input in the .json file
[{"FIRSTNAME":"barc","EMAIL":"jahg@jh.com","ADDRESS":"gyuyj"},
{"FIRSTNAME":"rth","EMAIL":"tht@thuyj.com","ADDRESS":"ytju"},
{"FIRSTNAME":"trhy","EMAIL":"klo@pyu.com","ADDRESS":"trght"},
{"FIRSTNAME":"ghy","EMAIL":"ytj@uki.com","ADDRESS":"ukyk"}]

output is required as .csv file(in each row its specified columns should be added)
"FIRSTNAME":"barc","rth","trhy","ghy"
"EMAIL":"jahg@jh.com","tht@thuyj.com","klo@pyu.com","ytj@uki.com"
"ADDRESS":"gyuyj","ytju","trght","ukyk"
"LASTNAME":"rgrg","thjuh","sygrbuir","yugfb"
"SALARY":"5665","5476","4565","5677"

as shown the difference between input file and output, lastname and salary are added.
similarly others fields should be added dynamically to the corresponding columns(even if it is given from other file).

What have you coded so far?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.