Adding the CSV module to the script

For this script, we will use the CSV module, a useful module to create Comma Separated Value spreadsheets. Its simple syntax will make it a useful tool to create script outputs. It should be noted that ArcGIS for Desktop also installs the xlrd and xlwt modules, used to read or generate Excel spreadsheets respectively, when it is installed.

Just below the import arcPy line, add import csv. This will allow us to use the csv module to create the spreadsheet:

# Import arcpy module
import arcpy
import csv

The next adjustment is made to the Intersect tool. Notice that the two paths included in the input string are also defined as variables in the variable section. Remove the file paths from the input strings and replace ...

Get ArcPy and ArcGIS – Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.