473,395 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

"shelve" save object

Hi there!
I am using the "shelve" module in a script to save information in
between runtime sessions of the program. (its a sort of
data collector, so its important to hold on to anything computed ).
In any case, I shelve into a file "test.txt". I notice that when i try
running the program on a different computer (by either emailing or
transfering the file "test.txt" via USB key), the program is unable to
load the shelve file.
What can I do to fix this? It would be a great shame to see that after
collecting all this information and shelving it that I cannot move to
another computer or share the information through the "save.txt" file.

Thanks in advance!
Jon
Aug 9 '08 #1
2 2158
On Aug 10, 5:32 am, hypermonkey2 <jonmo...@gmail.comwrote:
Hi there!
I am using the "shelve" module in a script to save information in
between runtime sessions of the program. (its a sort of
data collector, so its important to hold on to anything computed ).
In any case, I shelve into a file "test.txt". I notice that when i try
running the program on a different computer (by either emailing or
transfering the file "test.txt" via USB key), the program is unable to
load the shelve file.
What can I do to fix this? It would be a great shame to see that after
collecting all this information and shelving it that I cannot move to
another computer or share the information through the "save.txt" file.
For a start, you could consider telling us what "unable to load the
shelve file" means ... please copy any error message, exception
information and traceback and paste it into your response. Showing the
code that deals with the shelf file would also be useful; we don't
want to guess what your shelve.open args are.

.... "on a different computer": How many different computers? How many
times? To check the possibility that the file was mangled in transit
between computers, have you compared the filesize and md5 checksum
before and after transport?

When asking questions like this, it's a very good idea to state what
computer platform, what version of what OS, and what version of
Python. In your case, you need to report this info for both the
creating computer and the unable-to-load computers(s).

Try this on both the creating computer and the unable-to-load
computers(s), at the Python interactive prompt:
>>import whichdb
whichdb.whichdb('test.txt')
and report the results.

Also consider changing the name from "test.txt" to something
meaningful -- a file with a ".txt" extension is just begging silly
software and silly humans to treat it as a text file and mangle it.

HTH,
John
Aug 9 '08 #2
hypermonkey2 wrote:
In any case, I shelve into a file "test.txt". I notice that when i try
running the program on a different computer (by either emailing or
transfering the file "test.txt" via USB key), the program is unable to
load the shelve file.
You might find the 3rd party module 'shove' is more suitable for your
needs here.

http://pypi.python.org/pypi/shove

It provides a lot more backend support than shelve, of particular
interest to you would be filesystem (& maybe sqlite).
>>from shove import Shove
fsdb = Shove('file://persistent.db')
fsdb['key1'] = 'value1'
fsdb.close()
In this example, using the file protocol will produce a
'persistent.db' folder with the key/value pairs stored within it as
files. This should be cross platform enough for your needs.
Aug 11 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Johan Kohler | last post by:
Hi, I have a class with attributes that are string, integer and list. eg. class person: name ="" age = 0 friends= comment=""""""
3
by: Michele Petrazzo | last post by:
Hi, I'm trying a script on a debian 3.1 that has problems on shelve library. The same script work well on a fedora 2 and I don't know why it create this problem on debian: #extract from my code...
7
by: mwt | last post by:
Is there a function in python that does what "locate" does in a bash shell? I know I could do it by using os.popen('locate'), but I'm curious if there's a Python "native" way to go about it....
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 378 open ( +3) / 3298 closed (+34) / 3676 total (+37) Bugs : 886 open (-24) / 5926 closed (+75) / 6812 total (+51) RFE : 224 open...
1
by: Joe Peterson | last post by:
I've been doing a lot of searching on the topic of one of Python's more disturbing issues (at least to me): the fact that if a __del__ finalizer is defined and a cyclic (circular) reference is...
2
by: RayOsborn | last post by:
I have some old "shelve" databases created in Python 2.2 that use the old bsddb format, whereas the version of Python 2.4 installed by my web hosting service doesn't have bsddb available at all...
0
by: Edwin.Madari | last post by:
since choice of dbm used by shelve http://docs.python.org/lib/node327.html depends on os, and whats available on it, shevle files saved on one os, most likely do not work on another os, sometimes on...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.