Good day everyone. I am running this code in ArcPro and receive the following error:
It tells me that my input feature does not exist or is not supported. I have ran this script in python 2.7 and it all works fine. Thank all of you in advance.
#Import ArcPy modules
import arcpy
from arcpy import env
# Set the workspace
arcpy.env.workspace = "Database Connections/ADMIN Edit.sde/CustomerServiceFeatures"
ArcSDE = arcpy.env.workspace
env.overwriteOutput = True
# Set local variables
inFeatures = "GPS_Meter_CustomerServiceFieldCrew"
outputLocation = "X:/Planning/GIS/Meter GPS/GPS Meter Collection/Customer Service/GPS CC&B Joins"
outputFolderName = "00_00_19"
outputFolderLocation = "X:/Planning/GIS/Meter GPS/GPS Meter Collection/Customer Service/GPS CC&B Joins/00_00_19"
outputDatabase = "CC&B iPad Meters.gdb"
outputDatabaseLocation = "X:/Planning/GIS/Meter GPS/GPS Meter Collection/Customer Service/GPS CC&B Joins/00_00_19/CC&B iPad Meters.gdb"
outputFeatureClass = "GPS_Meter_CS"
expression = "SERVICEPOINTID IS NULL"
# Create folder
## UPDATE outputFolderName, outputFolderLocation, AND outputDatabaseLocation
## VARIABLE EVERYTIME THIS PROCESS RUNS WITH CURRENT DATE (MM_DD_YY).
print("Creating folder.")
arcpy.CreateFolder_management(outputLocation, outputFolderName)
# Create new .gdb
print("Creating geodatabase.")
arcpy.CreateFileGDB_management(outputFolderLocation, outputDatabase)
# Allow database to accept attachments.
print('Allowing attachments')
arcpy.env.maintainAttachments = True
# Export feature class geodatabase
print("Exporting feature class to feature class")
arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outputDatabaseLocation, outputFeatureClass, expression)
# Finish
print("Done")
Solved! Go to Solution.
It could have to do with your your workspace. Pro doesn't like the database connection links from what i gather.
You have to use C:\\Users\\***\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\**sde database**\\**Featuredataset**\\**feature class**. In Pro contents window navigate to the feature class then open Pro paython window drag the feature class to the very bottom python window and that should give you the path and use that for your layer paths.
Aslo you need to use the following below to set paths.
Python treats a backslash (\) as an escape character. I know it worked in 2.7 but not in 3.6 at least that what i have found.
"c:/temp/streams.shp
"c:\\temp\\streams.
gdb
"
"r"c:\temp\
It could have to do with your your workspace. Pro doesn't like the database connection links from what i gather.
You have to use C:\\Users\\***\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\**sde database**\\**Featuredataset**\\**feature class**. In Pro contents window navigate to the feature class then open Pro paython window drag the feature class to the very bottom python window and that should give you the path and use that for your layer paths.
Aslo you need to use the following below to set paths.
Python treats a backslash (\) as an escape character. I know it worked in 2.7 but not in 3.6 at least that what i have found.
"c:/temp/streams.shp
"c:\\temp\\streams.
gdb
"
"r"c:\temp\
Your last example should be
r"c:\temp\"
don't enclose the r in quotes, r precedes the first quote, whether single or double
Thank you all for your help and input.
Hey everyone, whenever I am trying to convert one feature class to another feature class I am getting an error (showed in image).Is it because of Chinese character that is not valid or what. I am bit new to these need help!!!
Thanks in advance
Krishan,
Try removing the space in your output feature class. Instead of "bridge location" try "bridgelocation" or "bridge_location". Hope this helps.
Thanks Hector, your solution works..