xlrd and cPickle.dump

patrick.waldo at gmail.com patrick.waldo at gmail.com
Tue Apr 1 06:36:52 EDT 2008


Hi all,

Sorry for the repeat I needed to reform my question and had some
problems...silly me.

The xlrd documentation says:
"Pickleable.  Default is true. In Python 2.4 or earlier, setting to
false will cause use of array.array objects which save some memory but
can't be pickled. In Python 2.5, array.arrays are used
unconditionally. Note: if you have large files that you need to read
multiple times, it can be much faster to cPickle.dump() the xlrd.Book
object once, and use cPickle.load() multiple times."

I'm using Python 2.4 and I have an extremely large excel file that I
need to work with.  The documentation leads me to believe that cPickle
will be a more efficient option, but I am having trouble pickling the
excel file.  So far, I have this:

import cPickle,xlrd
import pyExcelerator
from pyExcelerator import *

data_path = """C:\test.xls"""
pickle_path = """C:\pickle.xls"""

book = xlrd.open_workbook(data_path)
Data_sheet = book.sheet_by_index(0)

wb=pyExcelerator.Workbook()
proc = wb.add_sheet("proc")

#Neither of these work
#1) pyExcelerator try
#cPickle.dump(book,wb.save(pickle_path))
#2) Normal pickle try
#pickle_file = open(pickle_path, 'w')
#cPickle.dump(book, pickle_file)
#file.close()

Any ideas would be helpful.  Otherwise, I won't pickle the excel file
and deal with the lag time.

Patrick



More information about the Python-list mailing list