How to remove the "w" from these file geodatabase classes using ArcPy?

Tried this code snippet but does not work:

enter image description here

import arcpy
from arcpy import env
env.workspace = "C:\shared\NCWD\Testing\Castic_FGDB.gdb"
in_data = "wValve"
out_data = "Valve"
  • 1
    What happened when you tried this? The error messages provided by Python are always informative. – PolyGeo May 22 '17 at 20:25

since your in_data variable is a string you should be able to use in_data[1:] to get the string without the first character.

Edit: Sorry, I think I misread your question. I think you want to know how to remove the first character for all files in the file geodatabase. To do so you want to list all inside the database and loop through it and perform the Rename function.

For reference:



| improve this answer | |

Discovered the correct script!

import os

import arcpy

env.workspace = "C:/shared/NCWD/Testing/Castic_FGDB.gdb"

fcs = arcpy.ListFeatureClasses("c*","All","cWaterDistributionNetwork")

for fc in fcs:

print "all done"
| improve this answer | |

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.