how to fix TypeError: format requires a mapping
hinaimran.mehr at gmail.com
hinaimran.mehr at gmail.com
Wed Jul 1 17:57:14 EDT 2015
I am pulling my hair with this problem right now,
I have the following Data structure
[<OldSample {u'counter_name': u'cpu_util', u'user_id': u'id', u'resource_id': u'id', u'timestamp': u'2015-06-30T15:53:55', u'counter_volume': 0.043}]
I need to make it something like this to put in EON pubnub charting libaray (see link: http://www.pubnub.com/developers/eon/chart/spline/)
message: {
columns: [
["y": 0.043, "x": "2015-06-30T15:53:55"],
["y": 0.045, "x": "2015-06-30T15:53:55"]
]
Now I have the following code
data = cclient.samples.list(meter_name ='cpu_util', limit=2)
result_rows = []
for row in data:
formatted = """["y": %(counter_volume)0.3f, "x": "%(timestamp)s"]""" % (row)
result_rows.append(formatted)
print(',\n'.join(result_rows))
clean_json(data)
More information about the Python-list
mailing list