Python Forum
Dealing with a .json nightmare... ideas?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dealing with a .json nightmare... ideas?
#9
(Jan-28-2020, 05:24 PM)buran Wrote: @snippsat - probably id is unique per message, while body may be repeate
Yes of course agree,so a turn around.
>>> record = {}
>>> for item in json_data['messages']:
...     record[item['id']] = item['body']   
     
>>> record
{4461048: 'Mnow test test',
 4461049: 'test 9999',
 4620511: 'test sms,test sms',
 4620584: 'test sms',
 4646648: 'test sms',
 4646877: 'test sms',
 4671891: 'test sms'}

>>> record.get(4461049, 'Not in record')
'test 9999'

>>> record.get(9999999, 'Not in record')
'Not in record'
Reply


Messages In This Thread
RE: Dealing with a .json nightmare... ideas? - by snippsat - Jan-28-2020, 05:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel from SAP - dealing with formats and VBA MasterOfDestr 7 2,536 Feb-25-2024, 12:23 PM
Last Post: Pedroski55
  Python Pandas Syntax problem? Wrong Output, any ideas? Gbuoy 2 1,907 Jan-18-2023, 10:02 PM
Last Post: snippsat
  UnicodeEncodeError - Dealing with Japanese Characters fioranosnake 2 4,348 Jul-07-2022, 08:43 PM
Last Post: fioranosnake
  Help with coding/ideas natalie 6 3,218 Feb-12-2022, 03:16 PM
Last Post: deanhystad
  Dealing with duplicated data in a CSV file bts001 10 19,107 Sep-06-2021, 12:11 AM
Last Post: SamHobbs
  Looking for some ideas - Radius Log moralear27 1 2,625 Sep-10-2020, 09:32 PM
Last Post: micseydel
  Dealing with Exponential data parthi1705 11 13,072 May-30-2019, 10:16 AM
Last Post: buran
  some ideas for intelligent list splitting? wardancer84 4 4,356 Nov-20-2018, 02:47 PM
Last Post: DeaD_EyE
  Dealing with multiple context managers heras 5 7,398 Nov-16-2018, 09:01 AM
Last Post: DeaD_EyE
  dealing with big data of timestamp LMQ 0 2,651 Jul-27-2018, 01:23 PM
Last Post: LMQ

Forum Jump:

User Panel Messages

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