<?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: Workspace Issue Creating Layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/workspace-issue-creating-layer/m-p/1169042#M64430</link>
    <description>&lt;P&gt;Solved....changed line 25 to this and it worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;arcpy.MakeXYEventLayer_management(os.path.join(outputGDB, sheetName),'easting', 'northing', outLyr, spref)&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 20:31:05 GMT</pubDate>
    <dc:creator>ssintelmann</dc:creator>
    <dc:date>2022-04-28T20:31:05Z</dc:date>
    <item>
      <title>Workspace Issue Creating Layer</title>
      <link>https://community.esri.com/t5/python-questions/workspace-issue-creating-layer/m-p/1169036#M64429</link>
      <description>&lt;P&gt;Following on previous post, I imported a bunch of tables into GDB using ExcelToTable().&amp;nbsp; As such the workspace was set to the location of my Excel Files.&amp;nbsp; Tables import fine.&lt;/P&gt;&lt;P&gt;When try make a feature using&amp;nbsp;arcpy.MakeXYEventLayer_management later in script,&amp;nbsp;I get an error indicating the table doesn't exist, and the layer already exists.&amp;nbsp;&amp;nbsp;Is this how I have the workspace set, or am I really messing up some other way?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pandas as pd
import arcpy, os, re

# Variables
arcpy.env.workspace = r'C:\Data\working\EBS16\raw_sonar_files'
outputGDB = r"C:\Data\working\EBS16\EBS_16_analysis_display\default.gdb"
finalOUT = r"C:\Data\working\EBS16\EBS_16_analysis_display\default.gdb\em710vals\em50_"
spref = arcpy.SpatialReference(26903)
arcpy.env.overwriteOutput = True

try:
    for file in arcpy.ListFiles("*.xlsx"):
        f = os.path.join(arcpy.env.workspace, file)
        # Get excel sheets
        sheetNames = pd.ExcelFile(f).sheet_names
        # iterate through sheets
        for sheet in sheetNames:
            # Replace non alphanumeric characters with underscore
            sheetName = re.sub(r'[^0-9a-zA-Z]+', r'_', sheet)
            # create name for temp layer in XY event theme
            outLyr = sheetName + '_lyr'
            # Convert sheet to GDB table
            arcpy.conversion.ExcelToTable(f, os.path.join(outputGDB, sheetName), sheet, 1, '')
            # make XY Layer
            arcpy.MakeXYEventLayer_management(sheet,'easting', 'northing', outLyr, spref)
            outFeat =  finalOUT + sheetName # naming convention
            arcpy.management.CopyFeatures(outLyr, outFeat) # make lyr permanent
except Exception as e:
    print("Error: " + e.args[0])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 20:23:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/workspace-issue-creating-layer/m-p/1169036#M64429</guid>
      <dc:creator>ssintelmann</dc:creator>
      <dc:date>2022-04-28T20:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Workspace Issue Creating Layer</title>
      <link>https://community.esri.com/t5/python-questions/workspace-issue-creating-layer/m-p/1169042#M64430</link>
      <description>&lt;P&gt;Solved....changed line 25 to this and it worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;arcpy.MakeXYEventLayer_management(os.path.join(outputGDB, sheetName),'easting', 'northing', outLyr, spref)&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 20:31:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/workspace-issue-creating-layer/m-p/1169042#M64430</guid>
      <dc:creator>ssintelmann</dc:creator>
      <dc:date>2022-04-28T20:31:05Z</dc:date>
    </item>
  </channel>
</rss>

