<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using Search Cursor with Table to Excel Tool ArcPy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264662#M20390</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If nothing gets created, then there would be no records in the spreadsheet.&amp;nbsp; The tool will be used by a Public Safety department. They use the spreadsheets to get information for their reports.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The goal for the filename will include what kind of facility the list is being created for, as well as the buffer distance and units.&amp;nbsp; The end user could be running the tool on a feature with 3 records (1000-ft, 1500-ft, and 2000-ft).&amp;nbsp; In this example, the would get a spreadsheet for the 1000-ft buffer selected features, 1500-ft buffer selected features, and 2000-ft buffer selected features for each kind of vulnerable facility.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jun 2016 15:42:20 GMT</pubDate>
    <dc:creator>PatrickMcKinney1</dc:creator>
    <dc:date>2016-06-13T15:42:20Z</dc:date>
    <item>
      <title>Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264650#M20378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;&lt;STRONG&gt;Summary:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I am developing an ArcGIS Toolbox tool that will do the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;User selects a feature class that is a buffer of a site&lt;UL&gt;&lt;LI&gt;The number of features in this input layer will always be different&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;User selects an output folder for files created&lt;/LI&gt;&lt;LI&gt;Various layers in the same geodatabase are turned into Feature Layers&lt;/LI&gt;&lt;LI&gt;A search cursor is created for the input dataset&lt;/LI&gt;&lt;LI&gt;A for in loop is performed on the cursor (each record of the feature class)&lt;/LI&gt;&lt;LI&gt;In the loop, a select by location (intersect) is performed between the input layer and various layers&lt;/LI&gt;&lt;LI&gt;The selected features from each layer are converted to a spreadsheet&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The goal is to add field attributes (buffer distance and units) to each spreadsheet.&amp;nbsp; As the code stands now, no spreadsheets are created and I get the following message/error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'andale mono', times;"&gt;Executing: MakeFeatureLayer "\\CCPASR07\ncgs$\Scripts\ArcGIS Geoprocessing\SARA Tool\SARA_Tool_DEV.gdb\Site_Education" schools_lyr # # "OBJECTID OBJECTID VISIBLE NONE;SHAPE SHAPE VISIBLE NONE;Source_DatasetDesc Source_DatasetDesc VISIBLE NONE;Permanent_Identifier Permanent_Identifier VISIBLE NONE;Source_Originator Source_Originator VISIBLE NONE;LoadDate LoadDate VISIBLE NONE;Name Name VISIBLE NONE;Owner Owner VISIBLE NONE;Address1 Address1 VISIBLE NONE;City City VISIBLE NONE;State State VISIBLE NONE;Zip Zip VISIBLE NONE;PocName PocName VISIBLE NONE;PocOrganization PocOrganization VISIBLE NONE;PocTel1 PocTel1 VISIBLE NONE;PocEmail PocEmail VISIBLE NONE;Comments Comments VISIBLE NONE;State_FacilityID State_FacilityID VISIBLE NONE;FacilityID FacilityID VISIBLE NONE;FType FType VISIBLE NONE;FCode FCode VISIBLE NONE;Site_Plan_Link Site_Plan_Link VISIBLE NONE;Valid_Status Valid_Status VISIBLE NONE;Address2 Address2 VISIBLE NONE;Phone2 Phone2 VISIBLE NONE;Fax Fax VISIBLE NONE;NMFCID NMFCID VISIBLE NONE"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'andale mono', times;"&gt;Start Time: Fri Jun 10 14:33:24 2016&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'andale mono', times;"&gt;Succeeded at Fri Jun 10 14:33:24 2016 (Elapsed Time: 0.21 seconds)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I do not try to access the fields from the cursor, the first set of spreadsheets (from the first record) are created, but then the tool fails because of an already existing name for the spreadsheet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any tips for making this tool run as intended are much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Note: I do have &lt;/SPAN&gt;&lt;SPAN style="font-size: 16px;"&gt;the&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt; import arcpy code at the &lt;/SPAN&gt;&lt;SPAN style="font-size: 16px;"&gt;beginning&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# User selects risk radii layer as input for analysis
# SARA Risk Radius
#sara = arcpy.GetParameterAsText(0)


# User selects output folder
# outputFolder = arcpy.GetParameterAsText(1)
# Hard-coded for testing
outputFolder = r'\\CCPASR07\ncgs$\Scripts\ArcGIS Geoprocessing\SARA Tool\excel'


# Vulnerable Facilities Sites
# Create Feature Layers for analysis
# Repath for live testing/deployment


# file geodatabase containing vulnerable facilities
vsGdb = r'\\CCPASR07\ncgs$\Scripts\ArcGIS Geoprocessing\SARA Tool\SARA_Tool_DEV.gdb'
# Assisted Living
assistedLiving = vsGdb + '\EOC_AssistedLiving'
arcpy.MakeFeatureLayer_management(assistedLiving, 'assistedLiving_lyr')
# Daycares
daycares = vsGdb + '\EOC_Daycare'
arcpy.MakeFeatureLayer_management(daycares, 'daycares_lyr')
# Health Medical Sites
medical = vsGdb + '\Site_HealthMedical'
arcpy.MakeFeatureLayer_management(medical, 'medical_lyr')
# MHIDD Sites
mhIdd = vsGdb + '\EOC_MHIDD_Facility'
arcpy.MakeFeatureLayer_management(mhIdd, 'mhIdd_lyr')
# Schools
schools = vsGdb + '\Site_Education'
arcpy.MakeFeatureLayer_management(schools, 'schools_lyr')


# Hard-coded for input parameter for testing
sara = vsGdb + '\CarlislePumpShools'


try:


&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.SearchCursor(sara, fields="BUFFDIST; UNITS") # old cursor syntax


&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Having this block active fails tools
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Goal is to add buffer distance and units to file name of excel spreadsheet
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print(buffAppend)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicFileName = '_{0}_{1}_.xls'.format(str(row.getValue("BUFFDIST")), row.getValue("UNITS"))


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Assisted Living
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select Assisted Living sites that intersect SARA risk radius
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management('assistedLiving_lyr', 'INTERSECT', sara, "", 'NEW_SELECTION')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Export selected features to Excel
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableToExcel_conversion('assistedLiving_lyr', 'AssistedLiving' + dynamicFileName)


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Daycares
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select Daycares sites that intersect SARA risk radius
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management('daycares_lyr', 'INTERSECT', sara, "", 'NEW_SELECTION')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Export selected features to Excel
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableToExcel_conversion('daycares_lyr', 'Daycares' + dynamicFileName)


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Health Medical
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select Health Medical sites that intersect SARA risk radius
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management('medical_lyr', 'INTERSECT', sara, "", 'NEW_SELECTION')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Export selected features to Excel
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableToExcel_conversion('medical_lyr', 'Medical' + dynamicFileName)


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # MHIDD
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select MHIDD sites that intersect SARA risk radius
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management('mhIdd_lyr', 'INTERSECT', sara, "", 'NEW_SELECTION')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Export selected features to Excel
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableToExcel_conversion('mhIdd_lyr', 'MHIDD' + dynamicFileName)


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Schools
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select Schools sites that intersect SARA risk radius
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management('schools_lyr', 'INTERSECT', sara, "", 'NEW_SELECTION')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Export selected features to Excel
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableToExcel_conversion('schools_lyr', 'Schools' + dynamicFileName)


&amp;nbsp;&amp;nbsp;&amp;nbsp; del cursor


except Exception:
&amp;nbsp;&amp;nbsp;&amp;nbsp; e = sys.exc_info()[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(e.args[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(arcpy.GetMessages())&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:57:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264650#M20378</guid>
      <dc:creator>PatrickMcKinney1</dc:creator>
      <dc:date>2021-12-11T12:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264651#M20379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;line 52 str takes one argument you've given it two&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jun 2016 00:35:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264651#M20379</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-06-12T00:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264652#M20380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if the fields return values, then it should work&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = 'make_a_name_called_{0}_{1}_.xls'.format(10, "mm")
&amp;gt;&amp;gt;&amp;gt; a
'make_a_name_called_10_mm_.xls'&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:57:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264652#M20380</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T12:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264653#M20381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I first looked at it, it looked like both fields were in the same str. I don't see where you've used outputFolder as part of you're output paths.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jun 2016 02:38:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264653#M20381</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-06-12T02:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264654#M20382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;report the error message, perhaps its source lies within the section you have omitted&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jun 2016 06:12:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264654#M20382</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-12T06:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264655#M20383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With Lines 20, 23, 26, 29, and 32; I recommend you either add a second backslash, change the backslash to forward slash, or use raw notation with the second string.&amp;nbsp; Although it has been working for you so far, using a single backslash the way you are is asking for headaches at some point since a backslash is an escape character in Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See &lt;A href="https://docs.python.org/2/reference/lexical_analysis.html#string-literals"&gt;String literals &lt;/A&gt;in the Python documentation:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and use different rules for interpreting backslash escape sequences.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now that I think about it, using the &lt;A href="https://docs.python.org/2/library/os.path.html"&gt;os.path &lt;/A&gt;module is probably the best advice I can give for working with file system paths.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jun 2016 15:06:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264655#M20383</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-06-12T15:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264656#M20384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and who could forget that brilliant blog post &lt;A href="https://community.esri.com/migration-blogpost/55463"&gt;Filenames and file paths in Python&lt;/A&gt;&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt; that serves to point out some of the foibles of people trying to find the true path&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jun 2016 16:58:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264656#M20384</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-12T16:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264657#M20385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dynamicFileName = '_{0}_{1}_.xls'.format(str(row.getValue("BUFFDIST")), row.getValue("UNITS"))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1st argument = str(row.getValue("BUFFDIST")) &lt;/P&gt;&lt;P&gt;2nd argument = row.getValue("UNITS")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 14:13:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264657#M20385</guid>
      <dc:creator>PatrickMcKinney1</dc:creator>
      <dc:date>2016-06-13T14:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264658#M20386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need {0} to pull from a Double field, not hardcode a value in.&amp;nbsp; Do I need to use the string conversion method?&amp;nbsp; Or will it automatically force it into a string because the variable is already a string?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 14:15:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264658#M20386</guid>
      <dc:creator>PatrickMcKinney1</dc:creator>
      <dc:date>2016-06-13T14:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264659#M20387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the message I received, which I provided in the post:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'andale mono', times;"&gt;Executing: MakeFeatureLayer "\\CCPASR07\ncgs$\Scripts\ArcGIS Geoprocessing\SARA Tool\SARA_Tool_DEV.gdb\Site_Education" schools_lyr # # "OBJECTID OBJECTID VISIBLE NONE;SHAPE SHAPE VISIBLE NONE;Source_DatasetDesc Source_DatasetDesc VISIBLE NONE;Permanent_Identifier Permanent_Identifier VISIBLE NONE;Source_Originator Source_Originator VISIBLE NONE;LoadDate LoadDate VISIBLE NONE;Name Name VISIBLE NONE;Owner Owner VISIBLE NONE;Address1 Address1 VISIBLE NONE;City City VISIBLE NONE;State State VISIBLE NONE;Zip Zip VISIBLE NONE;PocName PocName VISIBLE NONE;PocOrganization PocOrganization VISIBLE NONE;PocTel1 PocTel1 VISIBLE NONE;PocEmail PocEmail VISIBLE NONE;Comments Comments VISIBLE NONE;State_FacilityID State_FacilityID VISIBLE NONE;FacilityID FacilityID VISIBLE NONE;FType FType VISIBLE NONE;FCode FCode VISIBLE NONE;Site_Plan_Link Site_Plan_Link VISIBLE NONE;Valid_Status Valid_Status VISIBLE NONE;Address2 Address2 VISIBLE NONE;Phone2 Phone2 VISIBLE NONE;Fax Fax VISIBLE NONE;NMFCID NMFCID VISIBLE NONE"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'andale mono', times;"&gt;Start Time: Fri Jun 10 14:33:24 2016&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'andale mono', times;"&gt;Succeeded at Fri Jun 10 14:33:24 2016 (Elapsed Time: 0.21 seconds)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 14:15:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264659#M20387</guid>
      <dc:creator>PatrickMcKinney1</dc:creator>
      <dc:date>2016-06-13T14:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264660#M20388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If nothing gets selected by the select by location, then nothing gets created and I suggest you print out what this is returning before using it in the table to excel 'MHIDD' + dynamicFileName&amp;nbsp; why is that being prepended to the dynamicFileName&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 14:26:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264660#M20388</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-13T14:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264661#M20389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Clearly the BuffDist and Units fields you are using to modify the spreadsheet names do not contain unique combinations for each feature.&amp;nbsp; If the first and second feature both have a BuffDist of 50 and a Units of 2 then the code will work for the first feature and fail for the second feature with a report that the spreadsheet name already exists.&amp;nbsp; You need to make sure that the spreadsheet file names are always unique.&amp;nbsp; You should add a counter value to each set of spreadsheet names or some other field to the file name that ensures that each set of spreadsheets is uniquely named.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 14:30:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264661#M20389</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-06-13T14:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264662#M20390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If nothing gets created, then there would be no records in the spreadsheet.&amp;nbsp; The tool will be used by a Public Safety department. They use the spreadsheets to get information for their reports.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The goal for the filename will include what kind of facility the list is being created for, as well as the buffer distance and units.&amp;nbsp; The end user could be running the tool on a feature with 3 records (1000-ft, 1500-ft, and 2000-ft).&amp;nbsp; In this example, the would get a spreadsheet for the 1000-ft buffer selected features, 1500-ft buffer selected features, and 2000-ft buffer selected features for each kind of vulnerable facility.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 15:42:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264662#M20390</guid>
      <dc:creator>PatrickMcKinney1</dc:creator>
      <dc:date>2016-06-13T15:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264663#M20391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The layer the select by location is based upon will be the output of a multi-ring buffer.&amp;nbsp; And I would like to add the Name field to the output.&amp;nbsp; This, combined with the user selecting the folder to place the spreadsheets should take care of this issue.&amp;nbsp; However, I agree adding a counter would he helpful.&amp;nbsp; I couldn't figure this out. Perhaps you could provide some sample code in addition to your advice?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 15:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264663#M20391</guid>
      <dc:creator>PatrickMcKinney1</dc:creator>
      <dc:date>2016-06-13T15:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264664#M20392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adding a counter only requires the code modification below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;try&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;:&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important;"&gt;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.SearchCursor(sara, fields=&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"BUFFDIST; UNITS"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;) &lt;/SPAN&gt;&lt;SPAN class="comment" style="font-weight: inherit; font-style: inherit; color: #008200; font-size: 9pt !important; background-color: inherit;"&gt;# old cursor syntax&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter = 0&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;for&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; row &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; cursor:&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="background-color: inherit; color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: black; font-size: 9pt; font-style: inherit; font-weight: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicFileName = &lt;/SPAN&gt;&lt;SPAN class="string" style="font-style: inherit; font-weight: inherit; color: blue; font-size: 9pt !important;"&gt;'_{0}&lt;SPAN style="color: #0000ff; font-size: 12px;"&gt;_{1}&lt;SPAN style="color: #0000ff; font-size: 12px;"&gt;_{2}&lt;/SPAN&gt;&lt;/SPAN&gt;_.xls'&lt;/SPAN&gt;&lt;SPAN style="color: black; font-style: inherit; font-weight: inherit; font-size: 9pt !important;"&gt;.format(str(row.getValue(&lt;/SPAN&gt;&lt;SPAN class="string" style="font-style: inherit; font-weight: inherit; color: blue; font-size: 9pt !important;"&gt;"BUFFDIST"&lt;/SPAN&gt;&lt;SPAN style="color: black; font-style: inherit; font-weight: inherit; font-size: 9pt !important;"&gt;)), row.getValue(&lt;/SPAN&gt;&lt;SPAN class="string" style="font-style: inherit; font-weight: inherit; color: blue; font-size: 9pt !important;"&gt;"UNITS"&lt;/SPAN&gt;&lt;SPAN style="color: black; font-style: inherit; font-weight: inherit; font-size: 9pt !important;"&gt;), counter)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have ArcGIS 10.1 or greater you really must convert the old cursor to the new da cursor to make it perform tolerably.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:57:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264664#M20392</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T12:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264665#M20393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To elaborate on what &lt;A href="https://community.esri.com/migrated-users/4811" target="_blank"&gt;Richard Fairhurst&lt;/A&gt;​ mentioned, creating unique files for each "row in cursor" could be as easy as&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;filecnt = 0
for row in cursor:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Having this block active fails tools&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Goal is to add buffer distance and units to file name of excel spreadsheet&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print(buffAppend)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; filecnt += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamicFileName = '_{0}_{1}_{2}.xls'.format(str(row.getValue("BUFFDIST")), row.getValue("UNITS"), filecnt) &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But are you trying to create a new file for each row (for each type), or are you wanting to create one output file for each type with all the cursor results?&amp;nbsp; If you want one output for each, you could write all the results to arrays, then add them to a file to create each excel file at the end.&amp;nbsp; I do similar things like that.&amp;nbsp; I've attached a sample that I right to a csv fiel for each loop, then do the arcpy.TableToExcel_conversion at the end to go from the csv to the Excel file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: I got sidetracke before I submitted my comment...Richard already has the counter covered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:57:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264665#M20393</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T12:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor with Table to Excel Tool ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264666#M20394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 16:05:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-with-table-to-excel-tool-arcpy/m-p/264666#M20394</guid>
      <dc:creator>PatrickMcKinney1</dc:creator>
      <dc:date>2016-06-13T16:05:44Z</dc:date>
    </item>
  </channel>
</rss>

