Created
September 21, 2015 09:07
-
-
Save cindygis/7eff019d456af601aa9c to your computer and use it in GitHub Desktop.
Uses the python-docx package to write various properties of a feature class to docx format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
@date 15/09/2015 | |
@author Cindy Williams | |
Uses the python-docx package to write various | |
properties of a feature class to docx format. | |
''' | |
import arcpy | |
from docx import Document | |
arcpy.env.workspace = r"C:\Some\Arb\Folder\work.gdb" | |
doc = r"C:\Some\Arb\Folder\test.docx" | |
document = Document() | |
document.add_paragraph("This document contains a description of fields per feature class.") | |
for fc in arcpy.ListFeatureClasses(): | |
p = document.add_paragraph("Feature class: ") | |
p.add_run(fc).bold = True | |
p.add_run("\n") | |
table = document.add_table(rows=1, cols=2, style='Table Grid') | |
header_cells = table.rows[0].cells | |
header_cells[0].text = "Field Name" | |
header_cells[1].text = "Field Type" | |
for field in arcpy.ListFields(fc): | |
row_cells = table.add_row().cells | |
row_cells[0].text = field.name | |
row_cells[1].text = field.type | |
document.add_page_break() # Each feature class on its own page | |
document.save(doc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment