<?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: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078764#M61757</link>
    <description>&lt;P&gt;If you use append, set it and forget it; that is, create a script for the append, and start it at 4:55 pm just be fore you leave for the day and forget about it.&amp;nbsp; That saves you all the overhead of insert cursors, edit sessions, etc....&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jul 2021 16:37:24 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2021-07-14T16:37:24Z</dc:date>
    <item>
      <title>Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078730#M61750</link>
      <description>&lt;P&gt;Not sure what the issues is but I am trying to use arcpy.da.InsertCursor on a SDE feature class but keep getting the 'Can't open workspace' error.The feature-dateset is versioned.&lt;/P&gt;&lt;P&gt;edit = arcpy.da.Editor(workspace)&lt;BR /&gt;RuntimeError: cannot open workspace&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fc = r"C:\Users\***\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\***_***_***.sde\***.***.TEST\C***.***.Test"

workspace = os.path.dirname(fc)
#arcpy.env.workspace = r"C:\\Users\\***\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\Database Connections\\***_***.sde\\***.***.TEST"
#fc = "***.***.Test"

edit = arcpy.da.Editor(workspace)

# Edit session is started without an undo/redo stack for versioned data
#  (for second argument, use False for unversioned data)
edit.startEditing(True)

# Start an edit operation
edit.startOperation()

dsc = arcpy.Describe(fc1)
fields = dsc.fields

# List all field names except the OID field

fieldnames = [field.name for field in fields]

# Create cursors and insert new rows

with arcpy.da.SearchCursor(fc1,fieldnames) as sCur:
    with arcpy.da.InsertCursor(fc,fieldnames) as iCur:
        for row in sCur:
            iCur.insertRow(row)
del sCur

# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 15:52:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078730#M61750</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-07-14T15:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078752#M61753</link>
      <description>&lt;P&gt;As a matter of style, I prefer not to use words like workspace as a variable since it's in the env method.&amp;nbsp; I always use ws as the workspace.&amp;nbsp; Also, I notice that you use the r'' (raw text) but include \\.&amp;nbsp; That's the beauty of r''; there is no need to escape a slash.&amp;nbsp; Finally, what is the purpose of nesting the insert cursor within a search cursor?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.env.workspace = r'C:\temp\my.gdb'
ws = arcpy.env.workspace
fc = 'YourFeatureClassName'
...
...
...

edit = arcpy.da.Editor(ws)
edit.startEditing()
edit.startOperation()
...
...
...

edit.stopOperation()
edit.stopEditing(True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:21:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078752#M61753</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-07-14T16:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078754#M61754</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Usually the workspace is set to whatever the database is since that is where the edit session usually occurs, then you can specify the feature class(s) that you want to edit in that workspace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
arcpy.env.OverwriteWorkspace = True
workspace = r'database.sde' # or database.gdb
walk = arcpy.da.Walk(workspace, datatype="FeatureClass")

fcs = []

edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()

for dirpath, dirnames, filenames in walk:
    for filename in filenames:
        fcs.append(os.path.join(dirpath, filename))

for fc in fcs:
    geometryType = arcpy.Describe(fc).shapeType
    fcsname = os.path.basename(fc)
    name = os.path.splitext(fcsname)
    y = name[1].lstrip('.')
    print (y)
    
   #Insert code here#

edit.stopOperation()
edit.stopEditing(True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I typically do when editing a database. Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:49:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078754#M61754</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-07-14T16:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078761#M61756</link>
      <description>&lt;P&gt;Thanks for the replay. I have being trying different workspace formats, with r and \\, / etc. Thanks for the recommendations. I made changes based on your recommendations and I still get the darn 'cannot open workspace' error.&lt;/P&gt;&lt;P&gt;I am trying to see if inserCursor is faster then Append. In my current code the Append process just take to long so I thought I would try insertCursor.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:33:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078761#M61756</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-07-14T16:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078764#M61757</link>
      <description>&lt;P&gt;If you use append, set it and forget it; that is, create a script for the append, and start it at 4:55 pm just be fore you leave for the day and forget about it.&amp;nbsp; That saves you all the overhead of insert cursors, edit sessions, etc....&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:37:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078764#M61757</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-07-14T16:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078766#M61759</link>
      <description>&lt;P&gt;Your fc path includes the feature dataset but when you use os.path.dirname() it steps up to the feature dataset. You need to use the geodatabase as your workspace for Editor, not the feature dataset. Try something like this&lt;/P&gt;&lt;LI-CODE lang="python"&gt;workspace = r"C:\Users\***\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\***_***_***.sde"

fc = os.path.join(geodatabase, "***.***.TEST", "C***.***.Test")

edit = arcpy.da.Editor(workspace)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:39:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078766#M61759</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-07-14T16:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078767#M61760</link>
      <description>&lt;P&gt;I get "False" when I added the print(arcpy.Exists(workspace)).&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:40:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078767#M61760</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-07-14T16:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078769#M61762</link>
      <description>&lt;P&gt;Well that's a problem too. It should print &lt;FONT face="courier new,courier"&gt;True&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:42:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078769#M61762</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-07-14T16:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078789#M61764</link>
      <description>&lt;P&gt;I did try the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;workspace = r"C:\Users\***\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\***_***_***.sde"
fc1 = os.path.join("***.***.TEST","***.***.Test")


&amp;amp; 
workspace = r"C:\Users\***\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\***_***_***.sde"

fc1 = "***.***.TEST","***.***.Test"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;But adding the workspace to the os.path.join is what allowed me to edit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;workspace = r"C:\Users\***\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\***_***_***.sde"
fc1 = os.path.join(workspace,"***.***.TEST","***.***.Test") #adding workspace worked.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 17:16:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1078789#M61764</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-07-14T17:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1399198#M70120</link>
      <description>&lt;PRE&gt;fc = os.path.join(geodatabase, "***.***.TEST", "C***.***.Test")&lt;/PRE&gt;&lt;P&gt;What is "geodatabase"? Also why is there two feature classes after that?&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 18:47:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1399198#M70120</guid>
      <dc:creator>ajreeve</dc:creator>
      <dc:date>2024-03-21T18:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Editing issues, edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace</title>
      <link>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1399213#M70121</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/678615"&gt;@ajreeve&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;PRE&gt;fc = os.path.join(geodatabase, "***.***.TEST", "C***.***.Test")&lt;/PRE&gt;&lt;P&gt;What is "geodatabase"? Also why is there two feature classes after that?&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/678615"&gt;@ajreeve&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.python.org/3/library/os.path.html#os.path.join" target="_self"&gt;os.path.join&lt;/A&gt; takes a variable number of parameters. The first is the starting portion of the path and everything else will get combined with the starting path separated by a slash to build the whole path. In this case, geodatabase is a variable assumed to be defined somewhere else in the code (this is just a snippet). It could be something like:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;geodatabase = r"C:\temp\mydata.gdb"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The next to variables are the feature dataset name ("***.***.TEST"), and then the feature class name ("C***.***.Test"). So the fc variable would end up with something like:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;"C:\temp\mydata.gdb\C***.***.Test\***.***.TEST"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;EDIT:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;I think the code in my post is slightly misleading. It should probably be:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;workspace = r"C:\Users\***\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\***_***_***.sde"

fc = os.path.join(workspace, "***.***.TEST", "C***.***.Test")

edit = arcpy.da.Editor(workspace)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 21 Mar 2024 19:09:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-issues-edit-arcpy-da-editor-workspace/m-p/1399213#M70121</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2024-03-21T19:09:50Z</dc:date>
    </item>
  </channel>
</rss>

