Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regex on json file
#10
so roughly speaking all the "id" keys are objects in a big array. I have tried various variation of the simple code below but I keep getting TypeError: the JSON object must be str, bytes or bytearray, not TextIOWrapper
import json
import os
  
rootfile = r'C:\\Users\\homer\\dumps\\cosmodb-sample.json'
with open(rootfile,'r') as file:
    json_data = json.loads(file) 
    for docs in json_data[0]:
        print(docs)
Quote:[
{
"id": "company-channelruleprintermap-8913-$pc2$company$8913$uspc02",
"ChannelRuleCollections": [
{
"Name": "Peak",
"State": 0,
"Modified": "2020-01-10T08:34:34.8015346Z"
}
]
},
{
"id": "company-channelruleprintermap-8913-$pc2$company$8913$uspc02",
"ChannelRuleCollections": [
{
"Name": "Peak",
"State": 0,
"Modified": "2020-01-10T08:34:34.8015346Z"
}
]
},
]
Reply


Messages In This Thread
regex on json file - by senaint - May-05-2020, 05:45 AM
RE: regex on json file - by bowlofred - May-05-2020, 06:17 AM
RE: regex on json file - by buran - May-05-2020, 07:57 AM
RE: regex on json file - by senaint - May-05-2020, 04:15 PM
RE: regex on json file - by buran - May-05-2020, 04:24 PM
RE: regex on json file - by senaint - May-05-2020, 07:54 PM
RE: regex on json file - by buran - May-05-2020, 08:18 PM
RE: regex on json file - by senaint - May-05-2020, 09:49 PM
RE: regex on json file - by bowlofred - May-05-2020, 11:22 PM
RE: regex on json file - by senaint - May-06-2020, 12:37 AM
RE: regex on json file - by bowlofred - May-06-2020, 03:58 AM
RE: regex on json file - by buran - May-06-2020, 03:15 AM
RE: regex on json file - by buran - May-06-2020, 04:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encrypt data in json file help jacksfrustration 1 491 Mar-28-2024, 05:16 PM
Last Post: deanhystad
  parse json field from csv file lebossejames 4 943 Nov-14-2023, 11:34 PM
Last Post: snippsat
  Python Script to convert Json to CSV file chvsnarayana 8 2,823 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,460 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  search file by regex SamLiu 1 1,028 Feb-23-2023, 01:19 PM
Last Post: deanhystad
  Split pdf in pypdf based upon file regex standenman 1 2,340 Feb-03-2023, 12:01 PM
Last Post: SpongeB0B
  Converting a json file to a dataframe with rows and columns eyavuz21 13 5,343 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  validate large json file with millions of records in batches herobpv 3 1,415 Dec-10-2022, 10:36 PM
Last Post: bowlofred
  Writing to json file ebolisa 1 1,111 Jul-17-2022, 04:51 PM
Last Post: deanhystad
  Trying to parse only 3 key values from json file cubangt 8 3,838 Jul-16-2022, 02:05 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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