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

example1


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
example2

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
Thanks
tbaror
 
Posts: 10
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 irc.freenode.net!
User avatar
micseydel
 
Posts: 928
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 1 guest