0

I am really beginner in arcgis scripting. I was unable to find a solution of my problem, so I'm writing here.

My problem:

On my input I want some shapefiles. When I load them from ArcGis Tool, I obtain something like this:

'C:\Users\Steve\Disk Google\BP-Kaiser\In\Cesta_Clip.shp';
'C:\Users\Steve\Disk Google\BP-Kaiser\In\Pesina_Clip.shp';
'C:\Users\Steve\Disk Google\BP-Kaiser\In\SilniceDalnice_Clip.shp'
'C:/Users/Steve/Disk Google/BP-Kaiser/In/Cesta_Clip.shp'

I want to have these shapefiles in a list, so I convert it using split() function to look like this:

list = ["'C:/Users/Steve/Disk Google/BP-Kaiser/In/Cesta_Clip.shp'", "'C:/Users/Steve/Disk Google/BP-Kaiser/In/Pesina_Clip.shp'", "'C:/Users/Steve/Disk Google/BP-Kaiser/In/SilniceDalnice_Clip.shp'"]

And then I would like to work with it.

But if I use just a simple function:

arcpy.CopyFeatures_management(list[0], outWorkspace+"/copy.shp")

it doesn't work. But if I enter the path to the file directly, it works.

I think that it has to be something simple, but like I said I am really beginner.

If you wold like to help me, but you will need more information, write me please.

  • Welcome to gis.SE. When you write "it doesn't work", can you tell us what happens instead? Remember that we can't see your screen, so you have to describe it to us. It may also help if you can tell us your specific versions, and what other things you've already looked at (so we don't suggest that). Also, you might like to format your code (as PolyGeo did for you) - see the format tips. And one more thing - it looks like you have two kinds of directory separators ('\' and '/'). Can you check that it is exactly what you see? You can click edit below your question to update it as needed. – BradHards Jan 1 '14 at 22:14
2

You don't need the 'quotes' around the path name, ArcGIS is getting tripped up on that. Try this:

list = ["C:/Users/Steve/Disk Google/BP-Kaiser/In/Cesta_Clip.shp", "C:/Users/Steve/Disk Google/BP-Kaiser/In/Pesina_Clip.shp", "C:/Users/Steve/Disk Google/BP-Kaiser/In/SilniceDalnice_Clip.shp"]
arcpy.CopyFeatures_management(list[0], outWorkspace+"/copy.shp")
  • Ok, it works. Thanks. And one more question: How you propose to convert my "first" data obtained from ArcGis Tool to list without ' quotes ' around the path name? – kaisers Jan 1 '14 at 20:59
  • 1
    Use .strip("'"). values = [val.strip("'") for val in arcpy.GetParameterAsText(x).split(';')] – Jason Scheirer Jan 1 '14 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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