<?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 Trying to save multiple file types to same location while using the same file name. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/trying-to-save-multiple-file-types-to-same/m-p/84605#M6667</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey, &lt;/P&gt;&lt;P&gt;I'm trying to build a tool using model builder that I can use to input an Excel spreadsheet and create a shapefile and a KML that saves in the same folder and has the same file name. I want the KML file to automatically default to whatever my output is for the shapefile but i think I am going to have to use python to figure out this last part. I'm really new to this and just now learning writing script. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help me with the last portion of this script? I would really appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# -*- coding: utf-8 -*-&lt;/P&gt;&lt;P&gt;# ---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;# ExcelToShpPlusKML.py&lt;/P&gt;&lt;P&gt;# Created on: 2015-08-13 20:50:17.00000&lt;/P&gt;&lt;P&gt;#&amp;nbsp;&amp;nbsp; (generated by ArcGIS/ModelBuilder)&lt;/P&gt;&lt;P&gt;# Usage: ExcelToShpPlusKML &amp;lt;Input_Address_Locator&amp;gt; &amp;lt;Input_Table&amp;gt; &amp;lt;Output_Feature_Class&amp;gt; &lt;/P&gt;&lt;P&gt;# Description: &lt;/P&gt;&lt;P&gt;# ---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Import arcpy module&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Script arguments&lt;/P&gt;&lt;P&gt;Input_Address_Locator = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input_Table = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output_Feature_Class = arcpy.GetParameterAsText(2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Local variables:&lt;/P&gt;&lt;P&gt;Output_Table__2_ = Output_Feature_Class&lt;/P&gt;&lt;P&gt;Output_Table = Output_Table__2_&lt;/P&gt;&lt;P&gt;Output_Layer = Output_Table&lt;/P&gt;&lt;P&gt;Output_File = Output_Layer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Geocode Addresses&lt;/P&gt;&lt;P&gt;arcpy.GeocodeAddresses_geocoding(Input_Table, Input_Address_Locator, "", Output_Feature_Class, "STATIC")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Delete Field&lt;/P&gt;&lt;P&gt;arcpy.DeleteField_management(Output_Feature_Class, "")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Delete Rows&lt;/P&gt;&lt;P&gt;arcpy.DeleteRows_management(Output_Table__2_)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Make Feature Layer&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management(Output_Feature_Class, Output_Layer, "", "", "")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Layer To KML&lt;/P&gt;&lt;P&gt;arcpy.LayerToKML_conversion(Output_Layer, Output_File, "0", "false", "DEFAULT", "1024", "96", "CLAMPED_TO_GROUND")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Aug 2015 21:10:30 GMT</pubDate>
    <dc:creator>StephenLee2</dc:creator>
    <dc:date>2015-08-14T21:10:30Z</dc:date>
    <item>
      <title>Trying to save multiple file types to same location while using the same file name.</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-save-multiple-file-types-to-same/m-p/84605#M6667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey, &lt;/P&gt;&lt;P&gt;I'm trying to build a tool using model builder that I can use to input an Excel spreadsheet and create a shapefile and a KML that saves in the same folder and has the same file name. I want the KML file to automatically default to whatever my output is for the shapefile but i think I am going to have to use python to figure out this last part. I'm really new to this and just now learning writing script. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help me with the last portion of this script? I would really appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# -*- coding: utf-8 -*-&lt;/P&gt;&lt;P&gt;# ---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;# ExcelToShpPlusKML.py&lt;/P&gt;&lt;P&gt;# Created on: 2015-08-13 20:50:17.00000&lt;/P&gt;&lt;P&gt;#&amp;nbsp;&amp;nbsp; (generated by ArcGIS/ModelBuilder)&lt;/P&gt;&lt;P&gt;# Usage: ExcelToShpPlusKML &amp;lt;Input_Address_Locator&amp;gt; &amp;lt;Input_Table&amp;gt; &amp;lt;Output_Feature_Class&amp;gt; &lt;/P&gt;&lt;P&gt;# Description: &lt;/P&gt;&lt;P&gt;# ---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Import arcpy module&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Script arguments&lt;/P&gt;&lt;P&gt;Input_Address_Locator = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input_Table = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output_Feature_Class = arcpy.GetParameterAsText(2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Local variables:&lt;/P&gt;&lt;P&gt;Output_Table__2_ = Output_Feature_Class&lt;/P&gt;&lt;P&gt;Output_Table = Output_Table__2_&lt;/P&gt;&lt;P&gt;Output_Layer = Output_Table&lt;/P&gt;&lt;P&gt;Output_File = Output_Layer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Geocode Addresses&lt;/P&gt;&lt;P&gt;arcpy.GeocodeAddresses_geocoding(Input_Table, Input_Address_Locator, "", Output_Feature_Class, "STATIC")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Delete Field&lt;/P&gt;&lt;P&gt;arcpy.DeleteField_management(Output_Feature_Class, "")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Delete Rows&lt;/P&gt;&lt;P&gt;arcpy.DeleteRows_management(Output_Table__2_)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Make Feature Layer&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management(Output_Feature_Class, Output_Layer, "", "", "")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Layer To KML&lt;/P&gt;&lt;P&gt;arcpy.LayerToKML_conversion(Output_Layer, Output_File, "0", "false", "DEFAULT", "1024", "96", "CLAMPED_TO_GROUND")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2015 21:10:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-save-multiple-file-types-to-same/m-p/84605#M6667</guid>
      <dc:creator>StephenLee2</dc:creator>
      <dc:date>2015-08-14T21:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to save multiple file types to same location while using the same file name.</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-save-multiple-file-types-to-same/m-p/84606#M6668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking at your logic it appears that you're doing the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Geocode the table&lt;/LI&gt;&lt;LI&gt;Delete a field in the table&lt;/LI&gt;&lt;LI&gt;Empty the geocoding table (i.e. delete the results of geocoding step so that you have an empty table with the geocoding result schema)&lt;/LI&gt;&lt;LI&gt;Make a feature layer against the empty geocoding result table&lt;/LI&gt;&lt;LI&gt;Export the empty table to KML&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you explain why you're emptying the geocoded table? I'm guessing that some logic is missing and you're probably needing to delete certain rows that you don't need in the output table. I have pasted some logic below that should help you move forward with your task if you're still needing to do so, but I removed the logic you had in the middle because I don't fully understand what your business requirements are.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from os import path
arcpy.env.overwriteOutput = True
locator&amp;nbsp;&amp;nbsp; = arcpy.GetParameterAsText(0)
addrTable = arcpy.GetParameterAsText(1)
out_class = arcpy.GetParameterAsText(2)

''' STEP ONE : Create your shapefile '''
# Geocode the table of addresses you've provided with your chosen locator
locations = arcpy.geocoding.GeocodeAddresses(table, locator, "", out_class)

''' STEP TWO : Create your kml file next to your shapefile '''
# Create a layer object from your shapefile
alias = path.basename(out_class).split(".")[0]
layer = arcpy.management.MakeFeatureLayer(locations, '{0} Layer'.format(alias)).getOutput(0)
# Create the kml file
arcpy.conversion.LayerToKML(layer, out_class.replace(".shp", ".kmz"),0, False, "DEFAULT", 1024, 96, "CLAMPED_TO_GROUND")
def userWorkflow(locator, table, out_class):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # create your shapefile
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.geocoding.GeocodeAddresses(table, locator, "", out_class)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:14:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-save-multiple-file-types-to-same/m-p/84606#M6668</guid>
      <dc:creator>FreddieGibson</dc:creator>
      <dc:date>2021-12-10T23:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to save multiple file types to same location while using the same file name.</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-save-multiple-file-types-to-same/m-p/84607#M6669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Local variables:
Output_Table__2_ = Output_Feature_Class
Output_Table = Output_Table__2_
Output_Layer = Output_Table
Output_File = Output_Layer&lt;/PRE&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;^ this makes 4 copies of Output_Feature_Class. I'm guessing that's not what you're going for.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Can you post an error message or more explanation as to what exactly is going wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:14:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-save-multiple-file-types-to-same/m-p/84607#M6669</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-10T23:14:46Z</dc:date>
    </item>
  </channel>
</rss>

