-2

I need to convert a csv file into a JSON object (preferably using Python)

Input file is :

**Jun 28 23:59:56 MUM-NM-FG-FW/MUM-NM-FG-FW date=2014-06-28 time=23:59:59 devname=MUM-NM-FG-FW-PRI device_id=FG300C3911600511 log_id=0038000004 type=traffic subtype=other pri=notice vd=Sify-VDOM src=XXX.XXX.XXX.XXX src_port=60276 src_int="port5" dst=XXX.XXX.XXX.XXX 


Jun 28 23:59:56 MUM-NM-FG-FW/MUM-NM-FG-FW date=2014-06-28 time=23:59:59 devname=MUM-NM-FG-FW-PRI device_id=FG300C3911600511 log_id=0038000004 type=traffic subtype=other pri=notice vd=Sify-VDOM src=XXX.XXX.XXX.XXX  src_port=60277 src_int="port5" dst=XXX.XXX.XXX.XXX** 

Result is like:

{"date": "2014-06-28","time": "22:59:59","devname": "MUM-NM-FG-FW-PRI","device_id": "FG300C3911600511","log_id": "0038000004","type": "traffic","subtype": "other","pri": "notice","vd": "Sify-VDOM","src": "XXX.XXX.XXX.XXX","src_port": "60276","src_int": "port5","dst": "XXX.XXX.XXX.XXX" }

{"date": "2014-06-28","time": "22:59:59","devname": "MUM-NM-FG-FW-PRI","device_id": "FG300C3911600511","log_id": "0038000004","type": "traffic","subtype": "other","pri": "notice","vd": "Sify-VDOM","src": "XXX.XXX.XXX.XXX","src_port": "60277","src_int": "port5","dst": "XXX.XXX.XXX.XXX" }

Please help on this.

Madhusudhan
  • 11
  • 1
  • 5

1 Answers1

0

You can use the csv and json modules in python. Below a link that explain how to do it: http://www.idiotinside.com/2015/09/18/csv-json-pretty-print-python/