json.dump not correctly saving json objectSafely turning a JSON string into an objectHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How do I test for an empty JavaScript object?Why does Google prepend while(1); to their JSON responses?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?

Are there any tips to help hummingbirds find a new feeder?

why "American-born", not "America-born"?

Is a world with one country feeding everyone possible?

How to tease a romance without a cat and mouse chase?

Shell builtin `printf` line limit?

Why is Ni[(PPh₃)₂Cl₂] tetrahedral?

Make the `diff` command look only for differences from a specified range of lines

Keeping the dodos out of the field

Why is 'additive' EQ more difficult to use than 'subtractive'?

Way of refund if scammed?

Would this be a dangerous impeller to use for a drone?

Negative impact of having the launch pad away from the Equator

Why do the i8080 I/O instructions take a byte-sized operand to determine the port?

Are there historical examples of audiences drawn to a work that was "so bad it's good"?

What does it mean for something to be strictly less than epsilon for an arbitrary epsilon?

Real Analysis: Proof of the equivalent definitions of the derivative.

Nunc est bibendum: gerund or gerundive?

Why is this python script running in background consuming 100 % CPU?

How to eliminate gap at the start and at the end of a line when it's drawn along a side of a node's bounding box?

Meaning of "half-crown enclosure"

Can diplomats be allowed on the flight deck of a commercial European airline?

What defines a person who is circumcised "of the heart"?

Illustrating that universal optimality is stronger than sphere packing

Can someone get a spouse off a deed that never lived together and was incarcerated?



json.dump not correctly saving json object


Safely turning a JSON string into an objectHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How do I test for an empty JavaScript object?Why does Google prepend while(1); to their JSON responses?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a function that plots data on a graph fetched from a website, that data is serialized in dictionaries and saved to a file named 'data.json'. The first dictionary is saved without any outstanding issues, however the second dictionary accurately saves all but the newest entry to the dictionary.



I've tried saving the data in different ways, all resulting in the same issue. I've narrowed it down to the save_data() function, after a considerable amount of time surfing the World Wide Web I am still at an impasse.



Here is the save_data function:



def save_data():
with open('./data.json', 'w') as data_file:
json_object =
"sig_count_diff": ,
"total_sig_count":


for key, value in total_signature_count.items():
# print("For signature_count_difference: Key: " + str(key) + " Value: " + str(value))
json_object["total_sig_count"].update(str(key): value)

for key1, value1 in signature_count_difference.items():
# print("For signature_count_difference: Key1: " + str(key1) + " Value1: " + str(value1))
json_object["sig_count_diff"].update(str(key1): value1)


print(json_object)
json.dump(json_object, data_file)


Here is the animate function:



def animate(i):
raw_data = request.urlopen('https://petition.parliament.uk/petitions/241584.json').read()
json_data = json.loads(raw_data)
signature_count = json_data["data"]["attributes"]["signature_count"]
last_updated = parser.parse(json_data["data"]["attributes"]["updated_at"])

print("Last Updated: " + str(last_updated))
ax1.clear()

if len(total_signature_count) >= 1:
last_sig_key = total_signature_count[list(total_signature_count.keys())[-1]]

if last_sig_key == last_updated:
return

last_signature_count = total_signature_count[list(total_signature_count.keys())[-1]]
difference = signature_count - last_signature_count

if (difference > 0):
print("Difference: " + str(difference) + " Last Signature Count: " + str(last_signature_count) + " Signature Count: " + str(signature_count))
signature_count_difference.update(last_updated: difference)
print(signature_count_difference)
ax1.plot(signature_count_difference.keys(), signature_count_difference.values(), label="Unique Signatures")
print(signature_count_difference)

total_signature_count.update(last_updated: signature_count)
save_data()
ax1.plot(total_signature_count.keys(), total_signature_count.values(), label="Total Signature Count")



Here is a snippet of the console log:



Last Updated: 2019-03-23 20:49:37.538000+00:00
datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0
datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0
'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220
Last Updated: 2019-03-23 20:53:36.186000+00:00
=======> Difference: 3000 Last Signature Count: 4654220 Signature Count: 4657220
=== (signature_count_difference dict before it is saved)> datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 3000
datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 3000
=== (The JSON object supposedly saved)> 'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, '2019-03-23 20:53:36.186000+00:00': 3000, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220, '2019-03-23 20:53:36.186000+00:00': 4657220
Last Updated: 2019-03-23 20:53:36.186000+00:00
=== (The next iteration of animate, difference. The difference value (3000) doesn't seem to have been saved) >datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 0
datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 0
=== (JSON object of the next iteration, no entry with the value '3000' to be seen) > 'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, '2019-03-23 20:53:36.186000+00:00': 0, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220, '2019-03-23 20:53:36.186000+00:00': 4657220
Last Updated: 2019-03-23 20:53:36.186000+00:00



I expected the result to be saved and the value to be plotted on the graph.










share|improve this question




























    0















    I have a function that plots data on a graph fetched from a website, that data is serialized in dictionaries and saved to a file named 'data.json'. The first dictionary is saved without any outstanding issues, however the second dictionary accurately saves all but the newest entry to the dictionary.



    I've tried saving the data in different ways, all resulting in the same issue. I've narrowed it down to the save_data() function, after a considerable amount of time surfing the World Wide Web I am still at an impasse.



    Here is the save_data function:



    def save_data():
    with open('./data.json', 'w') as data_file:
    json_object =
    "sig_count_diff": ,
    "total_sig_count":


    for key, value in total_signature_count.items():
    # print("For signature_count_difference: Key: " + str(key) + " Value: " + str(value))
    json_object["total_sig_count"].update(str(key): value)

    for key1, value1 in signature_count_difference.items():
    # print("For signature_count_difference: Key1: " + str(key1) + " Value1: " + str(value1))
    json_object["sig_count_diff"].update(str(key1): value1)


    print(json_object)
    json.dump(json_object, data_file)


    Here is the animate function:



    def animate(i):
    raw_data = request.urlopen('https://petition.parliament.uk/petitions/241584.json').read()
    json_data = json.loads(raw_data)
    signature_count = json_data["data"]["attributes"]["signature_count"]
    last_updated = parser.parse(json_data["data"]["attributes"]["updated_at"])

    print("Last Updated: " + str(last_updated))
    ax1.clear()

    if len(total_signature_count) >= 1:
    last_sig_key = total_signature_count[list(total_signature_count.keys())[-1]]

    if last_sig_key == last_updated:
    return

    last_signature_count = total_signature_count[list(total_signature_count.keys())[-1]]
    difference = signature_count - last_signature_count

    if (difference > 0):
    print("Difference: " + str(difference) + " Last Signature Count: " + str(last_signature_count) + " Signature Count: " + str(signature_count))
    signature_count_difference.update(last_updated: difference)
    print(signature_count_difference)
    ax1.plot(signature_count_difference.keys(), signature_count_difference.values(), label="Unique Signatures")
    print(signature_count_difference)

    total_signature_count.update(last_updated: signature_count)
    save_data()
    ax1.plot(total_signature_count.keys(), total_signature_count.values(), label="Total Signature Count")



    Here is a snippet of the console log:



    Last Updated: 2019-03-23 20:49:37.538000+00:00
    datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0
    datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0
    'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220
    Last Updated: 2019-03-23 20:53:36.186000+00:00
    =======> Difference: 3000 Last Signature Count: 4654220 Signature Count: 4657220
    === (signature_count_difference dict before it is saved)> datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 3000
    datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 3000
    === (The JSON object supposedly saved)> 'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, '2019-03-23 20:53:36.186000+00:00': 3000, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220, '2019-03-23 20:53:36.186000+00:00': 4657220
    Last Updated: 2019-03-23 20:53:36.186000+00:00
    === (The next iteration of animate, difference. The difference value (3000) doesn't seem to have been saved) >datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 0
    datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 0
    === (JSON object of the next iteration, no entry with the value '3000' to be seen) > 'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, '2019-03-23 20:53:36.186000+00:00': 0, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220, '2019-03-23 20:53:36.186000+00:00': 4657220
    Last Updated: 2019-03-23 20:53:36.186000+00:00



    I expected the result to be saved and the value to be plotted on the graph.










    share|improve this question
























      0












      0








      0








      I have a function that plots data on a graph fetched from a website, that data is serialized in dictionaries and saved to a file named 'data.json'. The first dictionary is saved without any outstanding issues, however the second dictionary accurately saves all but the newest entry to the dictionary.



      I've tried saving the data in different ways, all resulting in the same issue. I've narrowed it down to the save_data() function, after a considerable amount of time surfing the World Wide Web I am still at an impasse.



      Here is the save_data function:



      def save_data():
      with open('./data.json', 'w') as data_file:
      json_object =
      "sig_count_diff": ,
      "total_sig_count":


      for key, value in total_signature_count.items():
      # print("For signature_count_difference: Key: " + str(key) + " Value: " + str(value))
      json_object["total_sig_count"].update(str(key): value)

      for key1, value1 in signature_count_difference.items():
      # print("For signature_count_difference: Key1: " + str(key1) + " Value1: " + str(value1))
      json_object["sig_count_diff"].update(str(key1): value1)


      print(json_object)
      json.dump(json_object, data_file)


      Here is the animate function:



      def animate(i):
      raw_data = request.urlopen('https://petition.parliament.uk/petitions/241584.json').read()
      json_data = json.loads(raw_data)
      signature_count = json_data["data"]["attributes"]["signature_count"]
      last_updated = parser.parse(json_data["data"]["attributes"]["updated_at"])

      print("Last Updated: " + str(last_updated))
      ax1.clear()

      if len(total_signature_count) >= 1:
      last_sig_key = total_signature_count[list(total_signature_count.keys())[-1]]

      if last_sig_key == last_updated:
      return

      last_signature_count = total_signature_count[list(total_signature_count.keys())[-1]]
      difference = signature_count - last_signature_count

      if (difference > 0):
      print("Difference: " + str(difference) + " Last Signature Count: " + str(last_signature_count) + " Signature Count: " + str(signature_count))
      signature_count_difference.update(last_updated: difference)
      print(signature_count_difference)
      ax1.plot(signature_count_difference.keys(), signature_count_difference.values(), label="Unique Signatures")
      print(signature_count_difference)

      total_signature_count.update(last_updated: signature_count)
      save_data()
      ax1.plot(total_signature_count.keys(), total_signature_count.values(), label="Total Signature Count")



      Here is a snippet of the console log:



      Last Updated: 2019-03-23 20:49:37.538000+00:00
      datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0
      datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0
      'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220
      Last Updated: 2019-03-23 20:53:36.186000+00:00
      =======> Difference: 3000 Last Signature Count: 4654220 Signature Count: 4657220
      === (signature_count_difference dict before it is saved)> datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 3000
      datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 3000
      === (The JSON object supposedly saved)> 'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, '2019-03-23 20:53:36.186000+00:00': 3000, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220, '2019-03-23 20:53:36.186000+00:00': 4657220
      Last Updated: 2019-03-23 20:53:36.186000+00:00
      === (The next iteration of animate, difference. The difference value (3000) doesn't seem to have been saved) >datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 0
      datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 0
      === (JSON object of the next iteration, no entry with the value '3000' to be seen) > 'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, '2019-03-23 20:53:36.186000+00:00': 0, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220, '2019-03-23 20:53:36.186000+00:00': 4657220
      Last Updated: 2019-03-23 20:53:36.186000+00:00



      I expected the result to be saved and the value to be plotted on the graph.










      share|improve this question














      I have a function that plots data on a graph fetched from a website, that data is serialized in dictionaries and saved to a file named 'data.json'. The first dictionary is saved without any outstanding issues, however the second dictionary accurately saves all but the newest entry to the dictionary.



      I've tried saving the data in different ways, all resulting in the same issue. I've narrowed it down to the save_data() function, after a considerable amount of time surfing the World Wide Web I am still at an impasse.



      Here is the save_data function:



      def save_data():
      with open('./data.json', 'w') as data_file:
      json_object =
      "sig_count_diff": ,
      "total_sig_count":


      for key, value in total_signature_count.items():
      # print("For signature_count_difference: Key: " + str(key) + " Value: " + str(value))
      json_object["total_sig_count"].update(str(key): value)

      for key1, value1 in signature_count_difference.items():
      # print("For signature_count_difference: Key1: " + str(key1) + " Value1: " + str(value1))
      json_object["sig_count_diff"].update(str(key1): value1)


      print(json_object)
      json.dump(json_object, data_file)


      Here is the animate function:



      def animate(i):
      raw_data = request.urlopen('https://petition.parliament.uk/petitions/241584.json').read()
      json_data = json.loads(raw_data)
      signature_count = json_data["data"]["attributes"]["signature_count"]
      last_updated = parser.parse(json_data["data"]["attributes"]["updated_at"])

      print("Last Updated: " + str(last_updated))
      ax1.clear()

      if len(total_signature_count) >= 1:
      last_sig_key = total_signature_count[list(total_signature_count.keys())[-1]]

      if last_sig_key == last_updated:
      return

      last_signature_count = total_signature_count[list(total_signature_count.keys())[-1]]
      difference = signature_count - last_signature_count

      if (difference > 0):
      print("Difference: " + str(difference) + " Last Signature Count: " + str(last_signature_count) + " Signature Count: " + str(signature_count))
      signature_count_difference.update(last_updated: difference)
      print(signature_count_difference)
      ax1.plot(signature_count_difference.keys(), signature_count_difference.values(), label="Unique Signatures")
      print(signature_count_difference)

      total_signature_count.update(last_updated: signature_count)
      save_data()
      ax1.plot(total_signature_count.keys(), total_signature_count.values(), label="Total Signature Count")



      Here is a snippet of the console log:



      Last Updated: 2019-03-23 20:49:37.538000+00:00
      datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0
      datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0
      'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220
      Last Updated: 2019-03-23 20:53:36.186000+00:00
      =======> Difference: 3000 Last Signature Count: 4654220 Signature Count: 4657220
      === (signature_count_difference dict before it is saved)> datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 3000
      datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 3000
      === (The JSON object supposedly saved)> 'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, '2019-03-23 20:53:36.186000+00:00': 3000, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220, '2019-03-23 20:53:36.186000+00:00': 4657220
      Last Updated: 2019-03-23 20:53:36.186000+00:00
      === (The next iteration of animate, difference. The difference value (3000) doesn't seem to have been saved) >datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 0
      datetime.datetime(2019, 3, 23, 20, 41, 38, 520000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 45, 38, 572000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 49, 37, 538000, tzinfo=tzutc()): 0, datetime.datetime(2019, 3, 23, 20, 53, 36, 186000, tzinfo=tzutc()): 0
      === (JSON object of the next iteration, no entry with the value '3000' to be seen) > 'sig_count_diff': '2019-03-23 20:41:38.520000+00:00': 0, '2019-03-23 20:45:38.572000+00:00': 0, '2019-03-23 20:49:37.538000+00:00': 0, '2019-03-23 20:53:36.186000+00:00': 0, 'total_sig_count': '2019-03-23 20:41:38.520000+00:00': 4648091, '2019-03-23 20:45:38.572000+00:00': 4651211, '2019-03-23 20:49:37.538000+00:00': 4654220, '2019-03-23 20:53:36.186000+00:00': 4657220
      Last Updated: 2019-03-23 20:53:36.186000+00:00



      I expected the result to be saved and the value to be plotted on the graph.







      python json matplotlib






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 21:08









      Duke Jake MorganDuke Jake Morgan

      217




      217






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Dictionaries can only contain a given key once. If you call .update(key: val) with a key that's already in the dict, it will replace the old value.



          It looks like you're getting the date string key '2019-03-23 20:53:36.186000+00:00' more than once, and when you update the dict, you lose its original value of 3000.






          share|improve this answer
































            0














            Ahah, I figured out the issue. A rather stupid blunder by myself. The difference is calculated by the last entry value and the current entry value, however they are both the same as I am attempting to calculate the difference after putting the current signature value into the same dictionary as the one I use to pull out the most recent value inserted into it.



            I wasn't thinking logically last night!



            Forgive the lack of linear thinking,
            Thanks!






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318409%2fjson-dump-not-correctly-saving-json-object%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              Dictionaries can only contain a given key once. If you call .update(key: val) with a key that's already in the dict, it will replace the old value.



              It looks like you're getting the date string key '2019-03-23 20:53:36.186000+00:00' more than once, and when you update the dict, you lose its original value of 3000.






              share|improve this answer





























                0














                Dictionaries can only contain a given key once. If you call .update(key: val) with a key that's already in the dict, it will replace the old value.



                It looks like you're getting the date string key '2019-03-23 20:53:36.186000+00:00' more than once, and when you update the dict, you lose its original value of 3000.






                share|improve this answer



























                  0












                  0








                  0







                  Dictionaries can only contain a given key once. If you call .update(key: val) with a key that's already in the dict, it will replace the old value.



                  It looks like you're getting the date string key '2019-03-23 20:53:36.186000+00:00' more than once, and when you update the dict, you lose its original value of 3000.






                  share|improve this answer















                  Dictionaries can only contain a given key once. If you call .update(key: val) with a key that's already in the dict, it will replace the old value.



                  It looks like you're getting the date string key '2019-03-23 20:53:36.186000+00:00' more than once, and when you update the dict, you lose its original value of 3000.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 23 at 22:02

























                  answered Mar 23 at 21:32









                  John GordonJohn Gordon

                  11.8k51833




                  11.8k51833























                      0














                      Ahah, I figured out the issue. A rather stupid blunder by myself. The difference is calculated by the last entry value and the current entry value, however they are both the same as I am attempting to calculate the difference after putting the current signature value into the same dictionary as the one I use to pull out the most recent value inserted into it.



                      I wasn't thinking logically last night!



                      Forgive the lack of linear thinking,
                      Thanks!






                      share|improve this answer



























                        0














                        Ahah, I figured out the issue. A rather stupid blunder by myself. The difference is calculated by the last entry value and the current entry value, however they are both the same as I am attempting to calculate the difference after putting the current signature value into the same dictionary as the one I use to pull out the most recent value inserted into it.



                        I wasn't thinking logically last night!



                        Forgive the lack of linear thinking,
                        Thanks!






                        share|improve this answer

























                          0












                          0








                          0







                          Ahah, I figured out the issue. A rather stupid blunder by myself. The difference is calculated by the last entry value and the current entry value, however they are both the same as I am attempting to calculate the difference after putting the current signature value into the same dictionary as the one I use to pull out the most recent value inserted into it.



                          I wasn't thinking logically last night!



                          Forgive the lack of linear thinking,
                          Thanks!






                          share|improve this answer













                          Ahah, I figured out the issue. A rather stupid blunder by myself. The difference is calculated by the last entry value and the current entry value, however they are both the same as I am attempting to calculate the difference after putting the current signature value into the same dictionary as the one I use to pull out the most recent value inserted into it.



                          I wasn't thinking logically last night!



                          Forgive the lack of linear thinking,
                          Thanks!







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 24 at 15:00









                          Duke Jake MorganDuke Jake Morgan

                          217




                          217



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318409%2fjson-dump-not-correctly-saving-json-object%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                              은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현