您的当前位置:首页正文

使用arcpy将dbf转换为excel

2021-05-25 来源:独旅网
该功能对应的是ArcGIS工具箱中的: Conversion Tools >> Excel >> Table to Excel#案例代码:

# -*- coding: utf-8 -*-import arcpy # 导入arcpy模块# 变量的初始化

clip = \"C:\\\\Users\\\\rui78\\\\Desktop\\\\New Folder\\\\clip.shp\"shp1 = \"C:\\\\Users\\\\rui78\\\\Desktop\\\\New Folder\\\\shp1.shp\"

shp1_Clip_shp = \"C:\\\\Users\\\\rui78\\\\Desktop\\\\New Folder\\\\result\\\\shp1_Clip.shp\"shp_dbf=\"C:\\\\Users\\\\rui78\\\\Desktop\\\\New Folder\\\\result\\\\shp1_Clip.dbf\"shp_exl=\"C:\\\\Users\\\\rui78\\\\Desktop\\\\New Folder\\\\result\\\\shp1_Clip.xls\"arcpy.Clip_analysis(shp1, clip, shp1_Clip_shp, \"\")print(\"剪切运算已完成\")#将计算结果转换成excel输出

arcpy.TableToExcel_conversion(shp_dbf,shp_exl)print(\"计算结果转excel已完成\")

下面是arcgis官方给出的arcpy模块下的TableToExcel_conversion()函数参考文档:TableToExcel_conversion(Input_Table, Output_Excel_File, 

{Use_field_alias_as_column_header}, {Use_domain_and_subtype_description}) Converts a table to a Microsoft Excel file.     INPUTS:

      Input_Table (Table View):

  The table to be converted to Microsoft Excel format.      Use_field_alias_as_column_header {Boolean}:  How column names in the output are determined.

  * NAME-Column headers will be set using the input's field names. This is the default.

  * ALIAS-Column headers will be set using the input's field aliases.      Use_domain_and_subtype_description {Boolean}:

  Controls how values from subtype fields or fields with a coded value domain are transferred to the output.

  * CODE-All field values will be used as they are stored in the table. This is the default.

  * DESCRIPTION-For subtype fields, the subtype description will be used. For fields with a coded value domain, the coded value descriptions will be used.     OUTPUTS:

      Output_Excel_File (File):  The output Microsoft Excel file.

因篇幅问题不能全部显示,请点此查看更多更全内容