Guest User

Untitled

a guest
May 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1. import arcpy
  2. Source_CSV = r"\int.ecDataStations.csv"
  3. Target_FC = r"Q:DataStations.gdbStations"
  4. Description = arcpy.Describe(Target_FC)
  5. Target_FC_name = Description.name
  6. Target_GDB = os.path.split(Description.catalogPath) [0]
  7. Temp_Layer = "Temp_Layer"
  8. SR = arcpy.Describe(Target_FC).spatialReference
  9. arcpy.MakeXYEventLayer_management(Source_CSV, "Lng", "Lat", Temp_Layer, SR, "")
  10. arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, "", "", "")
  11.  
  12. File "Q:scriptsCSVtoASMADPointFeatureClass.py", line 10, in <module>
  13. arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, "", "" , "")
  14. File "c:program files (x86)arcgisdesktop10.2arcpyarcpyconversion.py", line 1675, in FeatureClassToFeatureClass
  15. raise e
  16.  
  17. ExecuteError: ERROR 001156: Failed on input OID 1263820748, could not write value 'LS_ blue with white trim_ has overflow in Ruisseau Isabelle. Located between "Au P'tit Ruisseau" bar and Bas-Caraquet welcome sign_ just past Rue de Paul. A By-pass was reported at this LS on July 7_ 2012 and a temporary closed status zone was put in place. ' to output field Comment
  18. Failed to execute (FeatureClassToFeatureClass).
  19.  
  20. Comment
  21. Foo Bar - overflow to vegetated surface
  22. overflow to vegetated landscape
  23. overflow to field
  24. overflow to field
  25.  
  26. Flows into adjacent brook. station is close to lagoon this lift station serves a few homes - generally will pump 30 mins over two days. have 2 pumps
  27. Lift station #6 (Rue de l'Ile). No standby power_ dual pumps_ total capacity 500 gal. per min. Overflow pipe to Caraquet Harbour. In case of failure_ alarm system sends signal to pager of LS operator.
  28. LS situated on Chemin St Simon_ No. #7. Located in a small baby barn building off road.
  29. Propane backup; next to lagoon;
  30. October 2015: Back up will be installed at this site this year. Small grey shingled shack with RV dump station beside LS. Overflow_ near Ruisseau Isabelle. At small picnic park
  31. October 2015 - lite and buzzer small station - handles 3 houses and small campground. Lift station on Rue François Gionet. UTM estimated. This LS pumps at LS Parc Fondateur. less than 1 %
  32. october 2015 - no lites just pager; small flow station and no backup White lift station with siding. Situated at 2264 rue Industrielle. No red warning light_ nor backup power observed.
  33. Blue & white trim lift station on "rue du Lac". New sewage system being installed at time of inspection. LS services 24 houses on Rue du Lac. LS does not have an apparent overflow pipe nor backup power.
  34. LS_ blue with white trim_ has overflow in Ruisseau Isabelle. Located between "Au P'tit Ruisseau" bar and Bas-Caraquet welcome sign_ just past Rue de Paul. A By-pass was reported at this LS on July 7_ 2012 and a temporary closed status zone was put in place.
  35.  
  36. arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, field_mapping="""Comment "Comment" true true false 256 Text 0 0 ,First,#,Temp_Layer,Comment,-1,-1""")
  37.  
  38. c:Python27ArcGIS10.3python test.py
  39. Traceback (most recent call last):
  40. File "test.py", line 13, in <module>
  41. arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, field_mapping="""Comment "Comment" true true false 256 Text 0 0 ,First,#,Temp_Layer,Comment,-1,-1""")
  42. File "C:Program Files (x86)ArcGISDesktop10.3ArcPyarcpyconversion.py", line 1789, in FeatureClassToFeatureClass
  43. raise e
  44. arcgisscripting.ExecuteError: ERROR 001156: Failed on input OID -1, could not write value 'LS_ blue with white trim_ has overflow in Ruisseau Isabelle. Located between Au P'tit Ruisseau bar and Bas-Caraquet welcome sign_ just past Rue de Paul. A By-pass was reported at this LS on July 7_ 2012 and a temporary closed status zone was put in place. ' to output field Comment
  45. Failed to execute (FeatureClassToFeatureClass).
  46.  
  47. etc...
  48. Description = arcpy.Describe(Target_FC)
  49. Target_FC_name = Description.name
  50. Target_GDB = os.path.split(Description.catalogPath)[0]
  51. Temp_Layer = "Temp_Layer"
  52. SR = Description.spatialReference
  53. arcpy.MakeXYEventLayer_management(Source_CSV, "Lng", "Lat", Temp_Layer, SR, "")
  54. # arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, "", "", "")
  55. arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, field_mapping="""Comment "Comment" true true false 8000 Text 0 0 ,First,#,Temp_Layer,Comment,-1,-1""")
  56.  
  57. import arcpy, os
  58. Source_CSV = r"\int.ecDataStations.csv"
  59. Temp = os.environ.get('TEMP')
  60.  
  61. # replace single quotes with ~
  62. TempCSV = os.path.join(Temp,'Temp.csv')
  63. with open(Source_CSV,'r') as InFile:
  64. with open(TempCSV,'w') as OutFile:
  65. for Line in InFile:
  66. OutLine = Line.replace("'","~")
  67. OutFile.write(OutLine)
  68.  
  69. Target_FC = r"Q:DataStations.gdbStations"
  70. Description = arcpy.Describe(Target_FC)
  71. Target_FC_name = Description.name
  72. Target_GDB = os.path.split(Description.catalogPath) [0]
  73. Temp_Layer = "Temp_Layer"
  74. SR = arcpy.Describe(Target_FC).spatialReference
  75. arcpy.MakeXYEventLayer_management(Source_CSV, "Lng", "Lat", Temp_Layer, SR, "")
  76. arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, "", "", "")
  77.  
  78. # replace ~ with a single quote
  79. for ThisField in arcpy.ListFields(os.path.join(Target_GDB, Target_FC_name),field_type='String'):
  80. arcpy.CalculateField_management(os.path.join(Target_GDB, Target_FC_name),
  81. ThisField.name,'!{}!.replace("~","\'")'.format(ThisField.name),
  82. "PYTHON")
  83. os.remove(TempCSV) # get rid of the temp file
Add Comment
Please, Sign In to add comment