Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8286495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:47:17+00:00 2026-06-08T11:47:17+00:00

I have a dictionary let say: d = {a: 1, b: 2, c: 3

  • 0

I have a dictionary let say:

d = {"a": 1, "b": 2, "c": 3 }

All I want to do is to dump this dictionary into a file and then append
it with data produced by my program little by little. I don’t want to have
the dictionary data in memory during the running of the program. By the end I
want to be able to load this file into a python structure from another
program.

Is there a solution to do this using pickle or json or another python
module? I know that you can’t append to a dumped object in a pickle-file.

I know that I can do something like this:

d = pickle.load(open(fileName, 'rb'))
d.update(dictWithNewValues)
pickle.dump(d, open(fileName, 'wb'))

as described here. But I want to do it progressively.. I understand that this may be difficult to do that way because dictionary has unique keys, so to be append it the current keys should be known to avoid conflicts (entries with same keys..).

So, is there a way to do it in a list or another python object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:47:18+00:00Added an answer on June 8, 2026 at 11:47 am

    Assuming the keys of your dictionary are all strings, the simplest option I see is Python’s shelve module. A shelve behaves like a persistent dictionary, and any key can be updated.

    Another option is the anydbm module, which also requires all values to be strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a dictionary of names (a huge CSV file). I want
Let's say I have a text file with the following: line = this is
Let's say I have a grammar file with this code. // START:members @header {
Let's say I have a list: a = ['apple', 'carrot'] and a dictionary: d
Let's say I have the following dictionary in a small application. dict = {'one':
Let's say I have a Dictionary<String, Guid> What is the fastest way to convert
Let's say I have a Dictionary<string,object> like so: var foo = new Dictionary<string, object>();
Let's say that I have a dictionary of controls and strings. If I run
Let's say I have an NSDictionary with a nested NSDictionary like this (simplified, I
let's say I have the following dictionary : public Dictionary<Room, List<Booking>> rooms = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.