我試圖使用SciPy進行一些統計,但是我的輸入數據集非常大(〜1.9GB),並且採用dbf格式。 該文件足夠大,當我嘗試使用genfromtxt創建數組時,Numpy會返回錯誤消息。 (我有3GB內存,但運行win32)。通過PyTables或PyHDF「讀入」大文本文件到hdf5中?
即:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
ind_sum = numpy.genfromtxt(r"W:\RACER_Analyses\Terrestrial_Heterogeneity\IND_SUM.dbf", dtype = (int, int, int, float, float, int), names = True, usecols = (5))
File "C:\Python26\ArcGIS10.0\lib\site-packages\numpy\lib\npyio.py", line 1335, in genfromtxt
for (i, line) in enumerate(itertools.chain([first_line, ], fhd)):
MemoryError
從其他文章中,我看到,PyTables提供的分塊陣可能是有用的,但我的問題是首先讀取這些數據。或者換句話說,PyTables或PyHDF可以很容易地創建一個所需的HDF5輸出,但是我應該怎麼做才能首先將數據存入數組?
例如:
import numpy, scipy, tables
h5file = tables.openFile(r"W:\RACER_Analyses\Terrestrial_Heterogeneity\HET_IND_SUM2.h5", mode = "w", title = "Diversity Index Results")
group = h5.createGroup("/", "IND_SUM", "Aggregated Index Values"`)
,然後我既可以創建一個表或數組,但我怎麼指回原來的DBF數據?在描述中?
感謝您的任何想法!
如果他的輸入文件是1.9GB,他可能無法將其映射到32位操作系統上,並且仍然有地址空間用於他的python代碼來執行轉換。 – user57368 2011-01-07 23:13:07