Questions tagged [shelve]

Shelve can refer to either a Python object persistence or a pending change in a Visual Studio Workspace

A shelf in Python is a persistent, dictionary-like object. Documentation: shelve

Shelve can also refer to a pending change in the workspace within Visual Studio 2005

351 questions
3
votes
1 answer

python 3.x restore variables from pickle

I have dozens of variables in a dictionary in a pickle. If certain conditions are true, I need to restore all of these variables (all different types), with the same names as the dict's keys. I simplified the code to point out the problem. For…
weather guy
  • 397
  • 1
  • 3
  • 17
3
votes
3 answers

prefetch numpy arrays from disk?

I'm working with a bunch of numpy arrays that don't all fit in RAM, so I need to periodically save them to and load them from the disk. Usually, I know which ones I'll need to read ahead of time, so I'd like to hide the latency by issuing something…
MWB
  • 11,740
  • 6
  • 46
  • 91
3
votes
2 answers

Python: Append to list owned by an instance stored in shelved dictionary

So I'm writing a script to keep track of my correspondence. It takes the name of someone who emailed me, looks for its associated 'Friend object' in a shelved dictionary of Friend instances (or creates itself a new instance and stores it in the…
3
votes
1 answer

Python 2.7 program (w/ shelved dictionaries) returning fatal "dbrunrecoveryerror" for particular key and value combinations, but not others

I'm having a strange error when assigning certain values to certain keys in my program's dictionary (which is shelved and has approximately 14000 entries currently), a sample output I've pasted at the bottom of this post. Brief example is if I…
Josh
  • 321
  • 1
  • 2
  • 6
3
votes
1 answer

How can I recover data from a possibly corrupt, or too large Python Shelve db?

I've been using Shelve as a document store. The key is a stringified integer and the value is just some html in a string. Unfortunately my script ended up putting so many entries in the db that errors occurred (I don't have the exact ones to hand).…
Johnny
  • 31
  • 2
3
votes
1 answer

Is shelve really slow and taking a lot of memory or am I doing something wrong?

I'm trying to write a program that uses a shelve database of sorted letters as key, and a list of words that can be created from them as values. e.g: db['mnoo'] = ['moon', 'mono'] So I wrote a function that takes a filename and loads it into a…
Nescio
  • 513
  • 4
  • 13
3
votes
2 answers

Visual Studio 2008 TFS Shelve/Unshelve changes stopped working and hangs VS

Greetings. This is second time I've actually spotted this problem with VS 2008 TS with TFS addon installed on top. The problem is that at some point, when you actively work with Shelve/Unshelve changes from TFS, the Shelve changes window (when you…
Igor Malin
  • 652
  • 2
  • 8
  • 26
3
votes
1 answer

shelve archives not openable on other computer

I have saved some objects with shelve. In an other file I was able to restore these objects. But when I copy the archive to an other computer shelve gives me a _gdbm.error: File read error. The packages which hold the classes of the stored objects…
sauerburger
  • 4,569
  • 4
  • 31
  • 42
3
votes
2 answers

python populate a shelve object/dictionary with multiple keys

I have a list of 4-grams that I want to populate a dictionary object/shevle object with: ['I','go','to','work'] ['I','go','there','often'] ['it','is','nice','being'] ['I','live','in','NY'] ['I','go','to','work'] So that we have something…
hmghaly
  • 1,411
  • 3
  • 29
  • 47
3
votes
2 answers

Why does Python's shelve require that all keys be strings?

It's well-documented that Python's shelve module requires all keys to be strings and that there are various workarounds (see threads here and here). My question is, why does shelve require string keys? Given that I can pickle a dict that uses other…
kuzzooroo
  • 6,788
  • 11
  • 46
  • 84
3
votes
2 answers

Is there a maximum size for python's shelve module?

I'm getting this exception when trying to open shelve persisted files over a certain size which is actually pretty small (< 1MB) but I'm not sure where the exactly number is. Now, I know pickle is sort of the bastard child of python and shelve isn't…
Zac Witte
  • 135
  • 2
  • 5
3
votes
1 answer

How to add row separator to grid view in Android?

I want to add row separators in GridView. Basically I'm making a shelf app in which shelf will look like this: so number of columns can vary with device resolution and also when orientation is changed. How do I achieve this? any tricks ? I have…
Nayanesh Gupte
  • 2,735
  • 25
  • 37
3
votes
1 answer

is there a way to manually apply the diffs in hg unshelve -i output?

hg shelve did it again - even after applying the patch described in hg unshelve not working (which worked happily for about a month), shelve just "lost" all my changes again. I see the name of my shelve when running hg shelve -l, but when I do hg…
Jer
  • 5,468
  • 8
  • 34
  • 41
2
votes
1 answer

python shelve is not saving/loading

When I save/load my workspace via functions in a subfile, shelve doesn't work (test1). However, if I do the same in one file, it works (test2). Why is that? How can I fix the problem for the first case? In the main file: # in saveWS.py # to…
yufiP
  • 103
  • 6
2
votes
1 answer

Shelve module in Python 3.1.1

I'm new to Python and learning through the O'Reilly "Learning Python" series. I'm stuck on a shelve example and can't figure out why the program doesn't work. I'm trying to build some sample data and then load it into a shelve file. The weird…
Will Fogel
  • 81
  • 4