I have tried to load a JSON
file in pandas with this code
and I have this error in the fist line. I think that same thing is wrong in json structure because I tried also with pd.read_json
and it didn't work. What is wrong here?
Name_file='data582750.txt'
l=[]
with open(Name_file) as f:
for line in f:
l.append(line)
data = json.loads(l)
json_normalize(data)
I get this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-64-c050037c7cb9> in <module>()
----> 1 data = json.loads(l)
C:\Users\demighaa\AppData\Local\Continuum\Anaconda2\lib\json\__init__.pyc in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
337 parse_int is None and parse_float is None and
338 parse_constant is None and object_pairs_hook is None and not kw):
--> 339 return _default_decoder.decode(s)
340 if cls is None:
341 cls = JSONDecoder
C:\Users\demighaa\AppData\Local\Continuum\Anaconda2\lib\json\decoder.pyc in decode(self, s, _w)
362
363 """
--> 364 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
365 end = _w(s, end).end()
366 if end != len(s):
TypeError: expected string or buffer
The first line in the file is :
'{"Operator":0,"Device":"F0FCC","Time":1494854190,"FormattedTime":"2017-05-15 15:16:30 +0200 CEST","Data":"042911e3c78f2193262c58b2","JSONDecodedData":"{"Service":{"S":{"Typ":0,"Version":2,"Vdd":0},"Cpt":2,"Start":0},"ExtTemperature":[22.25,21.5,21.5,21.5,21.5,22],"Moisture":[50,50,49,49,49,50],"IntTemperature":[0,0,0,0,0,0,0,0,0]}","Snr":"48.21","ComputedLocation":{"Lat":0,"Lng":0},"LinkQuality":"EXCELLENT"}\n'