1
I have a JSON file with this data:
{
"in_reply_to_screen_name": null,
"favorited": false,
"id_str": "92",
"entities": {
"user_mentions": [],
"symbols": [],
"urls": [],
"hashtags": [
{
"indices": [0,8]
}
]
},
"geo": null,
"user": {
"verified": false,
"notifications": null,
"profile_sidebar_border_color": "FFFFFF",
"geo_enabled": true,
"profile_background_tile": true,
"url": null,
"id": 278,
"default_profile": false,
"lang": "pt",
"location": null,
"translator_type": "none",
"protected": false
},
"id": 92,
"in_reply_to_status_id_str": null,
"in_reply_to_status_id": null,
"created_at": "Tue Oct",
"is_quote_status": false,
"text": "Esta \u00e9 a vdd",
"truncated": false,
"retweeted": false
}
How can I delete the key/value pair that contains value null
, false
and true
of this file using Python?
Knowing that these values that should be deleted appear in various parts of the dictionary and when I try to do:
with open(arq_geral,'r') as f:
for line in f:
tweet = json.loads(line)
dados_tweet.append(tweet)
for tweet in dados_tweet:
if tweet["geo"]:
del tweet["geo"]
It does not remove geo, for example.