I have written a script to convert a CSV into a Feature Class. The actual line that does the conversion is the very last line in the script in which I call the
Here is my Code Snippet:
import arcpy Source_CSV = r"\\int.ec\Data\Stations.csv" Target_FC = r"Q:\Data\Stations.gdb\Stations" Description = arcpy.Describe(Target_FC) Target_FC_name = Description.name Target_GDB = os.path.split(Description.catalogPath)  Temp_Layer = "Temp_Layer" SR = arcpy.Describe(Target_FC).spatialReference arcpy.MakeXYEventLayer_management(Source_CSV, "Lng", "Lat", Temp_Layer, SR, "") arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, "", "", "")
I am getting the following error:
File "Q:\scripts\CSVtoASMADPointFeatureClass.py", line 10, in <module> arcpy.FeatureClassToFeatureClass_conversion(Temp_Layer, Target_GDB, Target_FC_name, "", "" , "") File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\conversion.py", line 1675, in FeatureClassToFeatureClass raise e 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 Failed to execute (FeatureClassToFeatureClass).
The value that
FeatureClassToFeatureClass could not write is from the 14th row in the CSV. I assume
FeatureClassToFeatureClass proceeds sequentially through the CSV, which if correct tells me it had no problem with any of the cell values in the previous lines.
Here are the first 14 rows from my CSV's "Comment" field:
Comment Foo Bar - overflow to vegetated surface overflow to vegetated landscape overflow to field overflow to field 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 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. LS situated on Chemin St Simon_ No. #7. Located in a small baby barn building off road. Propane backup; next to lagoon; 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 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 % 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. 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. 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.
It has been suggested that the problem is with the single quotation mark in "P'tit", as shown in the error message.
The only problem is P'tit is part of a legitimate place name entered by someone else. I need every character in the comments field to be transferred.
Further, it has been suggested that the problem is not so much with
FeatureClassToFeatureClass as it is the CSV converter not escaping single apostrophes.
If this is the problem what coding will force the CSV converter to escape single apostrophes?