I have a problem in using the in_memory function in a Python-script.

I have a shapefile test.shp with 3 fields (Alter, Geschlecht, Anzahl) and 2 rows of data. When I am using arcpy.CopyFeatures_management to copy the shapefile to in_memory it deletes the data of the rows.

I wrote a little test-script:

import arcpy

arcpy.env.workspace = "C:\\Python\\"

arcpy.CopyFeatures_management("in_memory/test", "test1.shp")

You can download the shapefiles here: https://www.dropbox.com/sh/b47og9rjfevpi7v/AAB_YLz1l_eY3b-lFJPm9kP9a?dl=0

test1.shp is empty (rows are still here but without data) and test2.shp is an correct copy.

Can someone tell me what is going wrong?

  • Can you edit your question and copy in your code? May 3, 2018 at 20:39
  • It sounds like you have an empty selection on C:\python\test.shp but if this is the start of your script and you're running outside ArcMap that shouldn't apply. Considering you're using a language other than english it may be that your fields contain characters that the workspace doesn't like... how annoying that would be. Can you try it again but with fields like 'F1,F2,F3' and values with english only characters, that will tell us if we're barking up the right tree. I can't download those files, dropbox gives an empty zip. May 4, 2018 at 0:40
  • I also uploaded it on google drive: drive.google.com/open?id=14c7yTa1tFaFsZTPoWznKp5h2d6a3Lx4a As mentioned below it is not a general problem with in_memory, but with this specific file (and some other files I am working with).
    – Christoph
    May 4, 2018 at 7:13

2 Answers 2


I also confirmed it with 10.3.1. One potential work around is to load it into memory as a feature set. Then the copy features tool works.

Here you can see it is during the process of copying test.shp to in_memory where you lose the attributes.

results = arcpy.CopyFeatures_management("test.shp","in_memory/test")[0]

with arcpy.da.SearchCursor(results,["*"]) as sc:
     for row in sc:
         print row
#(1, (698585.7347000018, 242057.83449999988), None, None, None)
#(2, (698390.1845999993, 241798.5549999997), None, None, None)

However with a feature set you don't.

feature_set = arcpy.FeatureSet("test.shp")
with arcpy.da.SearchCursor(feature_set,["*"]) as sc:
     for row in sc:
         print row
#(0, (698585.7347000018, 242057.83449999988), u'0-1', u'w', 1.0)
#(1, (698390.1845999993, 241798.5549999997), u'1-2', u'w', 1.0)

I don't have access to ArcGIS 10.4.1, but I was able to replicate the issue with 10.3.1.

I imported the test.shp feature class into an empty file geodatabase, modified your test script and ran it. The results were as expected (i.e. attributes were copied into the in_memory feature class and copied out fine).

I also created my own dummy shapefile within ArcCatalog and ran it through your script. The results were as expected.

I think your issue is related to your input "test.shp", there is something about it that is not quite right.

  • Thanks Dan, I think you are right. I am using in_memory a lot and had never problems before, just with this shapefile (should have mentioned it before). So the problem might be in the structure of test.shp. Still don't understand why.
    – Christoph
    May 4, 2018 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.