Downloading a feature whose name has a "/" in it

2199
4
02-14-2012 09:11 AM
SarahRichards
New Contributor II
I am trying to write a script that downloads a feature from HRSA's geospatial warehouse, copies it to a geodatabase and then executes a bunch of other functions. I believe they are using ArcIMS.

I have successfully done this for several files already, but when I try to download the file called "Medically Underserved Areas/Populations" I get an error and I KNOW it has to do with that stupid forward slash! How do I go around this? I have not been able to find a FQDN of where this service is actually located. When I pull this service into ArcMap and look at it's Name and Alias, they are both the same.

A colleague recommended I put a backslash in front of the forward slash:


>>> MUA = "GIS Servers\\datawarehouse.hrsa.gov\\HGDW_Mapping\\Medically Underserved Areas\/Populations"
>>> print "(" + MUA + ")"
(GIS Servers\datawarehouse.hrsa.gov\HGDW_Mapping\Medically Underserved Areas\/Populations)


Which obviously doesn't work. I tried recording it as a raw string:

>>> MUA= r"GIS Servers\datawarehouse.hrsa.gov\HGDW_Mapping\Medically Underserved Areas/Populations"
>>> print "(" + MUA + ")"
(GIS Servers\datawarehouse.hrsa.gov\HGDW_Mapping\Medically Underserved Areas/Populations)


Which at least gets the right pathname, but when I try to actually CopyFeatures, it still fails.

>>> arcpy.CopyFeatures_management(MUA, "c:\\Default.gdb\\MUA_temp","","0","0","0")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 1943, in CopyFeatures
    raise e
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset GIS Servers\datawarehouse.hrsa.gov\HGDW_Mapping\Medically Underserved Areas/Populations does not exist or is not supported
 
Failed to execute (CopyFeatures).


I am really at a loss of where to go next. How can I tell python that "Medically Underserved Areas/Populations" is the actual name of the file it's looking for and to just ignore the "/"  - pretend like it's a space or something?

This is super frustrating! Can anyone help? Is there ANY other way to get this file on my computer by a script or tool? I will eventually program this to happen automatically, so I really don't want to have to manually do this...

Any help is greatly appreciated! Even if you just recommend giving up. At least then I can stop banging my head against the wall.
Tags (2)
0 Kudos
4 Replies
HenryColgate
Occasional Contributor
Have you tried using regular expressions?

http://docs.python.org/library/re.html
0 Kudos
SarahRichards
New Contributor II


http://docs.python.org/library/re.html


Thanks for your suggestion. I have read through that page and even the "gentler" page and am still at a loss. Could you maybe give me an example of what regular expression to use?

I'm sorry, I know I'm dense! Your help is much appreciated!
0 Kudos
HenryColgate
Occasional Contributor
Probably led you down the garden path with RE.  Sorry about that.

I have tried for a bit to solve the problem seeming as the data is openly available.  It seems to be really unrespsonsive to the point where I can't achieve it manually.  My gues is that if it can't be done manually it can't be done.

I even tried replicating the problem locally however I cannot create feature class names with a forward slash.

I would probably give it a miss or even contact the service provider and tell them about the problem.  They may even appreciate knowing their data is inaccessible.
0 Kudos
ChrisSnyder
Regular Contributor III
I think you can do this using string literals: http://docs.python.org/release/2.5.2/ref/strings.html

Somthing like:
file = r"C:\temp\test\my cow is really a cow" + '/' + "horse"
>>> print file
'C:\\temp\\test\\my cow is really a cow/ horse'


Windows won't let you name a file with a / or \, so I couldn't even test it...

Just an observation, but it is plain idiocy to name a file with a forward or backslash. As a "real user" of their data, you might have some good sway calling them up and complaining about their stupid file name...
0 Kudos