Python Forum
Replace null values in Json file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replace null values in Json file
#6
As I said - you have complex structure, so you need to check if the value is (for example) list/dict, then you need to check values within this data structure too.
In your example you have
Output:
u'user_mentions': [{u'id': 254599256, u'id_str': u'254599256', u'indices': [3, 11], u'name': u'Alejandro Fargosi', u'screen_name': u'fargosi'}]}, u'favorite_count': 0, u'favorited': False, u'filter_level': u'low', u'geo': None, u'id': 1005817329459097600L, u'id_str': u'1005817329459097600', u'in_reply_to_screen_name': None, u'in_reply_to_status_id': None}]
the value is list of dicts, and there are elements in the dict that has value None.
so it is at least two levels deep that you have to check

what is the best way to do it depends on your data and you know your data best
can you post example of your json file so that we can get better understanding of the data structure that you work with?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Replace null values in Json file - by burnsssss - Jun-10-2018, 05:08 PM
RE: Replace null values in Json file - by Grok_It - Jun-10-2018, 06:29 PM
RE: Replace null values in Json file - by buran - Jun-10-2018, 06:50 PM
RE: Replace null values in Json file - by burnsssss - Jun-11-2018, 07:50 AM
RE: Replace null values in Json file - by volcano63 - Jun-10-2018, 07:26 PM
RE: Replace null values in Json file - by buran - Jun-11-2018, 07:57 AM
RE: Replace null values in Json file - by volcano63 - Jun-11-2018, 08:18 AM
RE: Replace null values in Json file - by buran - Jun-11-2018, 08:44 AM
RE: Replace null values in Json file - by volcano63 - Jun-11-2018, 08:56 AM
RE: Replace null values in Json file - by burnsssss - Jun-11-2018, 08:52 AM
RE: Replace null values in Json file - by buran - Jun-11-2018, 08:58 AM
RE: Replace null values in Json file - by burnsssss - Jun-11-2018, 09:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encrypt data in json file help jacksfrustration 1 276 Mar-28-2024, 05:16 PM
Last Post: deanhystad
  parse json field from csv file lebossejames 4 797 Nov-14-2023, 11:34 PM
Last Post: snippsat
  Replace a text/word in docx file using Python Devan 4 3,637 Oct-17-2023, 06:03 PM
Last Post: Devan
  Need to replace a string with a file (HTML file) tester_V 1 796 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Python Script to convert Json to CSV file chvsnarayana 8 2,599 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,203 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  How to express null value klatlap 3 882 Mar-25-2023, 10:40 AM
Last Post: klatlap
  Converting a json file to a dataframe with rows and columns eyavuz21 13 4,697 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
Photo How to select NULL and blank values from MySQL table into csv python300 9 2,531 Dec-27-2022, 09:43 PM
Last Post: deanhystad
  validate large json file with millions of records in batches herobpv 3 1,313 Dec-10-2022, 10:36 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020