<?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 python to execute make x y layer event across all files within a given directory in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202933#M6923</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will need to set the full path if you haven't set your workspace in the environments of your script&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/using-environment-settings.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/using-environment-settings.htm"&gt;Using environment settings in Python—Geoprocessing and Python | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Oct 2019 18:20:59 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2019-10-11T18:20:59Z</dc:date>
    <item>
      <title>Using python to execute make x y layer event across all files within a given directory</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202930#M6920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create xy event layers that display data from csv tables as points, I would like to loop the normal make x y event layer through the directory that my files are stored in. This data has no georeference and that is accounted for within the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a function that lists out the files that in the directory I need. Then through a series of functions I can create a series of output filenames that correspond with the names of the input files that I have put into the function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I keep getting an error message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Python27\ArcGIS10.6\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript&lt;BR /&gt; exec codeObject in __main__.__dict__&lt;BR /&gt; File "D:\Documents\functions.py", line 47, in &amp;lt;module&amp;gt;&lt;BR /&gt; loop_event_layer(csv_list, layer_file)&lt;BR /&gt; File "D:\Documents\functions.py", line 44, in loop_event_layer&lt;BR /&gt; arcpy.MakeXYEventLayer_management(table = i, in_x_field = "X", in_y_field = "Y", out_layer = x, spatial_reference="{B286C06B-0879-11D2-AACA-00C04FA33C20};IsHighPrecision", in_z_field = "PI")&lt;BR /&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\management.py", line 7618, in MakeXYEventLayer&lt;BR /&gt; raise e&lt;BR /&gt;ExecuteError: Failed to execute. Parameters are not valid.&lt;BR /&gt;ERROR 000732: XY Table: Dataset 0 does not exist or is not supported&lt;BR /&gt;Failed to execute (MakeXYEventLayer).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code is below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;#and separates the name at the .csv to give the beginning of the name. The outputs of this new name list have new &lt;BR /&gt;#extensions added such as point and raster. &lt;BR /&gt;arcpy.env.workspace = "D:/Documents/PhD/GIS/Odhran.gdb/"&lt;BR /&gt;path = "C:/Users/MarPAMM/Desktop/Test_with_Ger_for_csv_raster_conversion/"&lt;BR /&gt;output = "D:/Documents/PhD/GIS/Odhran.gdb/"&lt;BR /&gt;entries = os.listdir(path)&lt;BR /&gt;extension = "result.csv"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def list_csv(x):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;csv_list = []&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for i in x:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if i.endswith(extension):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; csv_list.append(i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return csv_list&lt;BR /&gt; &lt;BR /&gt;csv_list = list_csv(entries)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def split_csv_name(x):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;filename = []&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;start = []&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for i in x:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;start, end = i.split(".")&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;filename.append(start)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return filename&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;output_file_beginning = split_csv_name(csv_list)&lt;BR /&gt;layer_extension = "_layer"&lt;BR /&gt;point_extension = "_point"&lt;BR /&gt;raster_extension = "_raster"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def join_name(x, extension):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;filename = []&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for i in x:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;filename.append(i + extension)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return filename&lt;BR /&gt;layer_file = join_name(output_file_beginning, layer_extension)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def loop_event_layer(input_file, output_file):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for i,x in zip(range(len(input_file)),range(len(output_file))):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.MakeXYEventLayer_management(table = i, in_x_field = "X", in_y_field = "Y", out_layer = x, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;spatial_reference="{B286C06B-0879-11D2-AACA-00C04FA33C20};IsHighPrecision", in_z_field = "PI")&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return x&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop_event_layer(csv_list, layer_file)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Oct 2019 11:34:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202930#M6920</guid>
      <dc:creator>GerardSummers</dc:creator>
      <dc:date>2019-10-11T11:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using python to execute make x y layer event across all files within a given directory</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202931#M6921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gerard&lt;/P&gt;&lt;P&gt;line numbers would help&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Throw a print statement in to ensure the path and filenames are correct (ie 'i' or Table)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Oct 2019 11:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202931#M6921</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-10-11T11:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using python to execute make x y layer event across all files within a given directory</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202932#M6922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The print output for list_csv gives the file names for all the files in a numpy array, this section of the code works fine, an example of it can be seen below:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;['R59_011_Z41_Copy_result.csv', 'R59_011_Z42_Copy_result.csv', 'R59_011_Z43_Copy_result.csv', 
'R59_011_Z44_Copy_result.csv', 'R59_011_Z46_Copy_result.csv', 'R59_011_Z47_Copy_result.csv', 
'R59_011_Z48_Copy_result.csv', 'R59_011_Z49_Copy_result.csv', 'R59_011_Z50_Copy_result.csv', 
'R59_011_Z52_Copy_result.csv', 'R59_011_Z53_Copy_result.csv', 'R59_011_Z54_Copy_result.csv', 
'R59_011_Z58_Copy_result.csv', 'R59_011_Z59_Copy_result.csv', 'R59_011_Z60_Copy_result.csv', 
'R59_011_Z61_Copy_result.csv', 'R59_011_Z62_Copy_result.csv', 'R59_011_Z63_Copy_result.csv', 
'R59_011_Z64_Copy_result.csv', 'R59_011_Z65_Copy_result.csv', 'R59_011_Z66_Copy_result.csv', 
'R59_011_Z67_Copy_result.csv', 'R59_011_Z68_Copy_result.csv', 'R59_011_Z69_Copy_result.csv', 
'R59_011_Z70_Copy_result.csv', 'R59_011_Z71_Copy_result.csv', 'R59_011_Z72_Copy_result.csv',
'R59_011_Z73_Copy_result.csv', 'R59_011_Z74_Copy_result.csv', 'R59_011_Z75_Copy_result.csv', 
'R59_011_Z76_Copy_result.csv', 'R59_011_Z77_Copy_result.csv', 'R59_011_Z78_Copy_result.csv', 
'R59_011_Z79_Copy_result.csv', 'R59_011_Z80_Copy_result.csv', 'R59_011_Z81_Copy_result.csv', 
'R59_011_Z82_Copy_result.csv', 'R59_011_Z83_Copy_result.csv', 'R59_011_Z84_Copy_result.csv', 
'R59_011_Z85_Copy_result.csv']&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My main issue is using these as a looping input for the &lt;SPAN style="background-color: #ffffff;"&gt;arcpy.MakeXYEventLayer_management() function. Looking at the input it might be an idea to just use the full directory rather than the filename and see if it works.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:10:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202932#M6922</guid>
      <dc:creator>GerardSummers</dc:creator>
      <dc:date>2021-12-12T16:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using python to execute make x y layer event across all files within a given directory</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202933#M6923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will need to set the full path if you haven't set your workspace in the environments of your script&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/using-environment-settings.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/using-environment-settings.htm"&gt;Using environment settings in Python—Geoprocessing and Python | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Oct 2019 18:20:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-python-to-execute-make-x-y-layer-event/m-p/202933#M6923</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-10-11T18:20:59Z</dc:date>
    </item>
  </channel>
</rss>

