How to update json file with python

This is the place for queries that don't fit in any of the other categories.

How to update json file with python

Postby tbaror » Tue Aug 20, 2013 7:13 pm

Hello All,

I have python utility i wrote that doing some WMI monitoring, the the data is written in that format


Code: Select all
CPU = [{'TS':'2013:12:03:30','CPUVALUES':['0','1','15']}]

Now i need occasionally update data that will look eventually like following

Code: Select all
 CPU = [{'TS':'2013:12:03:30','CPUVALUES':['0','1','15']},{'TS':'2013:14:00:30','CPUVALUES':['0','75','15']}]

Any suggestion how to accomplish that
Please advice
Posts: 13
Joined: Sun Jul 07, 2013 8:06 pm

Re: How to update json file with python

Postby micseydel » Tue Aug 20, 2013 9:10 pm

If you don't mind having double instead of single quotes, the builtin json module rocks.

If you want more help than us saying what the name of a module, I recommend you post some code attempt at solving your problem and ask as specific of questions as you want answers.
Join the #python-forum IRC channel on!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
Posts: 1810
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 5 guests