sanitize filename, the esri way


/ Published in: Python
Save to your folder(s)

courtesy of Luke Pinner @environment.gov.au


Copy this code and paste it in your HTML
  1. import arcgisscripting
  2. gp = arcgisscripting.create()
  3. inshape_1 = 'c:/temp/%s' % gp.ValidateTableName('feature1.shp')
  4. inshape_2 = 'c:/temp/%s' % gp.ValidateTableName('feature2.shp')
  5. outshape = 'c:/temp/%s.shp' % gp.ValidateTableName('My-Merge-Output')
  6.  
  7. print inshape_1
  8. >>> >>> c:/temp/feature1_shp
  9. print inshape_2
  10. >>> >>> c:/temp/feature2_shp
  11. print outshape
  12. >>> >>> c:/temp/My_Merge_Output.shp
  13.  
  14. # Note; don't use on full path!
  15. print gp.ValidateTableName('c:/temp/My-Merge-Output.shp')
  16. >>> >>> c__temp_My_Merge_Output_shp

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.