编程语言
首页 > 编程语言> > arcgis python 表属性转html

arcgis python 表属性转html

作者:互联网

import arcpy
import sys
import string
import os

tablePath = arcpy.GetParameterAsText(0)
filePath = arcpy.GetParameterAsText(1)

outfile = open(filePath, "w")
fields = arcpy.ListFields(tablePath)

fieldNames = []
for field in fields:
    if (field.type <> "Geometry" and field.type <> "BLOB"):
        fieldNames.append(field.name)
outfile.write("<table border=""1"">\n")
outfile.write("<tr>\n")

for fieldName in fieldNames:
    outfile.write("<th>" + fieldName + "</th>\n")
outfile.write("</tr>\n")

for row in arcpy.da.SearchCursor(tablePath, fieldNames):
    outfile.write("<tr>\n")
    for value in row:
        outfile.write(u"<td>" + str(value) + "</td>\n")
    outfile.write("</tr>\n")
outfile.write("</table>\n")

outfile.flush()
outfile.close()

 

标签:field,outfile,python,fieldNames,write,arcgis,html,import,arcpy
来源: https://www.cnblogs.com/gisoracle/p/11396181.html