import pysal as ps
def dbf2DF(dbfile, upper=True):
"Read dbf file and return pandas DataFrame"
with ps.open(dbfile) as db: # I suspect just using open will work too
df = pd.DataFrame({col: db.by_col(col) for col in db.header})
if upper == True:
df.columns = map(str.upper, db.header)
return df
编辑2:
可以通过
dbfread
(只需使用pip install dbfread
安装)逐行读取dbf文件,无需转换为csv:我更新的参考资料:
正式项目地点:http://pandas.pydata.org
官方文件:http://pandas-docs.github.io/pandas-docs-travis/
dbfread
:https://pypi.python.org/pypi/dbfread/2.0.6geopandas
:http://geopandas.org/带
geopandas
:https://gis.stackexchange.com/questions/129414/only-read-specific-attribute-columns-of-a-shapefile-with-geopandas-fiona的shp and dbf从网上看,有几个选择:
使用simpledbf:
根据要点调整:
使用my dbf library可以执行以下操作:
它将创建与每个dbf文件同名的
.csv
文件。如果将该代码放入名为dbf2csv.py
的脚本中,则可以将其称为相关问题 更多 >
编程相关推荐