-1

trying to read my json data but it shows this error while using pandas

import pandas as pd
data=pd.read_json(r"1_lines.json")
print(data)

error

ValueError: Key name of object must be 'string' when decoding 'object'

my_json

{1: [((86, 27, 169, 50), 'PSEG'), ((323, 33, 408, 41), 'Total amount due'), ((499, 26, 591, 44), '$26,930.17'), ((85, 53, 195, 63), 'We make things work for you.')], 
2: [((427, 24, 560, 31), ' LLC'), ((422, 35, 560, 42), 'Your account number: 4246'), ((454, 44, 560, 50), 'Invoice Number: 60438'), ((53, 82, 170, 93), 't Metering Program')]}

when using other code

import json
json_data= open("1_lines.json").read()
json_obj=json.loads(json_data)
print(json_obj)

error

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)```
Robin
  • 49
  • 1
  • 9

1 Answers1

0

your my_json is dictionaty and not json. T0 convert json from dictionary

import json
a=json.dumps(my_json)
Meet
  • 164
  • 2
  • 11