<?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: Can Arcpy accept input as file-like object? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287724#M67608</link>
    <description>&lt;P&gt;You are able to use the memory workspace in geoprocessing tools, according to the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm#ESRI_SECTION1_51638127F5D8473EA669F443388F8227" target="_self"&gt;documentation&lt;/A&gt;.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Use of memory-based workspaces in Python is only valid for geoprocessing tools. Memory is not a general-purpose virtual directory where you can write files or other data.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Wed, 10 May 2023 14:49:58 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-05-10T14:49:58Z</dc:date>
    <item>
      <title>Can Arcpy accept input as file-like object?</title>
      <link>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287713#M67607</link>
      <description>&lt;P&gt;I'm curious if arcpy methods that take as input a CSV or text file can accept a file-like object instead, so I don't have to write to disk before invoking.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if I have a dataframe df:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pandas as pd
from io import StringIO
import arcpy
s_buff = StringIO()
df.to_csv(s_buff)
arcpy.management.BearingDistanceToLine(s_buff, "memory\\output", "x", 'y', 'd', bearing_field="b")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This generates an error: Error in executing tool.&amp;nbsp; s_buff.read(), s_buff.seek(0) also generates errors.&amp;nbsp; I know I could write to a temporary file, but I'd rather not.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:37:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287713#M67607</guid>
      <dc:creator>Jay_Gregory</dc:creator>
      <dc:date>2023-05-10T14:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can Arcpy accept input as file-like object?</title>
      <link>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287724#M67608</link>
      <description>&lt;P&gt;You are able to use the memory workspace in geoprocessing tools, according to the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm#ESRI_SECTION1_51638127F5D8473EA669F443388F8227" target="_self"&gt;documentation&lt;/A&gt;.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Use of memory-based workspaces in Python is only valid for geoprocessing tools. Memory is not a general-purpose virtual directory where you can write files or other data.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 10 May 2023 14:49:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287724#M67608</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-05-10T14:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can Arcpy accept input as file-like object?</title>
      <link>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287735#M67609</link>
      <description>&lt;P&gt;Indeed, but I'm just working with a vanilla pandas dataframe.&amp;nbsp; The memory workspace is limited to the output of arcpy operations it seems.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 15:10:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287735#M67609</guid>
      <dc:creator>Jay_Gregory</dc:creator>
      <dc:date>2023-05-10T15:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can Arcpy accept input as file-like object?</title>
      <link>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287764#M67610</link>
      <description>&lt;P&gt;What about something like this?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import numpy as np
import pandas as pd
import arcgis
 
data = np.random.randint(5, 35, size=11)
df = pd.DataFrame(data, columns=['random_numbers'])

df.spatial.to_table(r'memory/processed_df')

arcpy.GetCount_management(r'memory/processed_df')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 15:40:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287764#M67610</guid>
      <dc:creator>DannyMcVey</dc:creator>
      <dc:date>2023-05-10T15:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Can Arcpy accept input as file-like object?</title>
      <link>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287842#M67614</link>
      <description>&lt;P&gt;That works! Thanks!&amp;nbsp; just have to deal with the overhead of importing the python api to access the GeoAccessor &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 17:17:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-arcpy-accept-input-as-file-like-object/m-p/1287842#M67614</guid>
      <dc:creator>Jay_Gregory</dc:creator>
      <dc:date>2023-05-10T17:17:02Z</dc:date>
    </item>
  </channel>
</rss>

