3

I am using python. eg, this is one line from the file:

{
    "name": "accelerator_pedal_position", 
    "value": 0,
    "timestamp": 1364310856.002000
}
styvane
  • 59,869
  • 19
  • 150
  • 156
  • Hi,Shraedha: If my answer work,would you mind select it as the Answer! (There is a green check mark on the lert side of my answer) – Aaron Mar 05 '15 at 07:35

1 Answers1

2

Use the datetime module

In [1]: import datetime

In [2]: timestamp = 1364310856.002000

In [3]: print datetime.datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
2013-03-26 23:14:16

If your json file contents only one line, you can try:

In [1]: import json

In [2]: import datetime

In [3]: with open(r'yourjsfile','r') as fh:
   ...:         jsfile = json.load(fh)
   ...:         ts =  jsfile['timestamp']
   ...:         print datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
   ...:

2013-03-26 23:14:16
Aaron
  • 2,383
  • 3
  • 22
  • 53