3
I need to remove parts of a JSON, but I don’t know how to do it
I’m converting the same to CSV, and when I convert the structure gets all weird
Follow print explaining better, what is marked in black, need to remove and what is in red need to keep.
Follow json referring what I need to convert:
{
"@odata.context":"url requisição",
"value":[
{
"cprq_cert_id":51,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
},
{
"cprq_cert_id":52,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
},
{
"cprq_cert_id":54,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
},
{
"cprq_cert_id":72,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
},
{
"cprq_cert_id":73,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
}
]
}
And also the python script I use to convert:
import csv
import json
infile = open("nomejson.json","r")
outfile = open("nomecsv.csv","w")
writer = csv.writer(outfile)
for row in json.loads(infile.read()):
writer.writerow(row)
By cell phone I can not see what is in the print. Have to put in the text of the question the text you highlighted in the image?
– Jefferson Quesado
So I actually identified another problem he’s putting bars in the json that don’t appear in the console output, so the json format is bad. Strange
– RodolfoTI
So the error is not reproducible? Should it be closed by "typo"? Or else it deserves you to answer it yourself
– Jefferson Quesado
It is not typing, in python output it works normal, but when I send pro json it gets the bars ( '' )
– RodolfoTI
then I think you should answer
– Jefferson Quesado
@Lacobus, maybe the counterbars are literal? See previous AP comments
– Jefferson Quesado
Then they appear when I run the following commands: with open(view+'. json', 'w') as outfile: json.dump(r. text, outfile)
– RodolfoTI