I've a table with paths like:
R:\Daten\geo_daten\GEOLOGIE\bodenuebersicht\daten\arcview\bodeneigenschaften\shape\bodeneigenschaften.shp
and want to copy this Feature somewhere else and delete in the location where it is?
What's wrong?
import arcpy, numpy arcpy.env.overwriteOutput = True InPath = r"R:\Karto\Geodaten_Archiv.txt" OutPath = r"R:\Daten\geo_daten\geodaten_archiv\SIC_2016_04_07" filename = open(InPath, 'r') arr = arcpy.da.TableToNumPyArray(InPath, "Datenpfad") for line in arr: print line arcpy.CopyFeatures_management(line, OutPath)
Solved! Go to Solution.
Forgot it was an array, see if this works
import arcpy, numpy ,os arcpy.env.overwriteOutput = True InPath = r"F:\Departments\GIS\Wes\PySripts\DanPatterson\Code4GeoNet\CopyTest\Paths.txt" OutPath = r"F:\Departments\GIS\Wes\PySripts\DanPatterson\Code4GeoNet\CopyTest\CopyTo" filename = open(InPath, 'r') #Not being used arr = arcpy.da.TableToNumPyArray(InPath, "Datenpfad") for line in arr: print line[0] print os.path.join(OutPath,os.path.basename(line)) arcpy.CopyFeatures_management(line[0], os.path.join(OutPath,os.path.basename(line[0])))
When you use print line in 8 what do you get. ON line 9 you are coping whatever is printed on line 8 but you are printing to the same name over and over. I didn't test this but you may need to do something similar to below
import arcpy, numpy ,os arcpy.env.overwriteOutput = True InPath = r"R:\Karto\Geodaten_Archiv.txt" OutPath = r"R:\Daten\geo_daten\geodaten_archiv\SIC_2016_04_07" filename = open(InPath, 'r') #Not being used arr = arcpy.da.TableToNumPyArray(InPath, "Datenpfad") for line in arr: print line arcpy.CopyFeatures_management(line, os.path.join(OutPath,os.path.basename(line)))
Thank you for your comment, but your idea leads to this:
(u'R:\\Daten\\geo_daten\\GEOLOGIE\\bodenuebersicht\\daten\\arcview\\bodeneigenschaften\\shape\\bodeneigenschaften.shp',)
Traceback (most recent call last):
arcpy.CopyFeatures_management(line, os.path.join(OutPath,os.path.basename(line)))
File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 198, in basename
return split(p)[1]
File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 170, in split
d, p = splitdrive(p)
File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 125, in splitdrive
if p[1:2] == ':':
IndexError: invalid index
What prints on line 8?
You originally said this ( see my comments in red😞 "
I've a table with paths like:
R:\Daten\geo_daten\GEOLOGIE\bodenuebersicht\daten\arcview\bodeneigenschaften\shape\bodeneigenschaften.shp
and want to copy this Feature somewhere else and delete in the location where it is?
What's wrong?
Here you point to a shapefile : R:\Daten\geo_daten\GEOLOGIE\bodenuebersicht\daten\arcview\bodeneigenschaften\shape\bodeneigenschaften.shp
Then you read from a text file in your code???
If you just want to copy a bunch of shapefiles from one location to the other, you could do something like this :
import sys, os, arcpy inPath = "some path here" outPath = "some other path here" arcpy.env.workspace = inPath shpIn = [for f in arcpy.ListFeatureClasses() if f.endswith(".shp")] for shp in shpIn: arcpy.CopyFeatures_management(shp, os.path.join(outPath, shp))
All this, more or less from :
Forgot it was an array, see if this works
import arcpy, numpy ,os arcpy.env.overwriteOutput = True InPath = r"F:\Departments\GIS\Wes\PySripts\DanPatterson\Code4GeoNet\CopyTest\Paths.txt" OutPath = r"F:\Departments\GIS\Wes\PySripts\DanPatterson\Code4GeoNet\CopyTest\CopyTo" filename = open(InPath, 'r') #Not being used arr = arcpy.da.TableToNumPyArray(InPath, "Datenpfad") for line in arr: print line[0] print os.path.join(OutPath,os.path.basename(line)) arcpy.CopyFeatures_management(line[0], os.path.join(OutPath,os.path.basename(line[0])))
If that works here is the Delete—Help | ArcGIS for Desktop help
line[0] was it, thanks a lot
Would like to mark your answer as the correct one, but there's only helpful and like buttons. Sorry wasn't here for a long time?
Johannes,
See if you can still change this from a "discussion" to a "question", then you should be able to check a correct answer. Timothy Hales can probably help if you aren't able to do this.