I have a CSV storing addresses, reference numbers, etc... and also a WKT string of boundary coordinates for each property:
The script (ammended from another user's post in 2012) sccessfully converts the CSV to a shapefile, with the spatial refeence set to EPSG- 27700:
# convert well known text to geometry, and compile shapes into a single feature class... # 11/15/2012 import arcpy File = "C:\\Users\\Team\\Documents\\Theo Laptop Folder\\Tasks\\Quick tasks\\WKTtest\\WKT_to_QGISmakealayerCSV2.csv" # dimension the WKT string field and poly ID field... # the field holding the WKT string... field1 = "WKT" # the field holding the unique ID... field2 = "Our_ref" # set up the empty list... featureList =  # set the spatial reference to a known EPSG code... sr = arcpy.SpatialReference(27700) # iterate on table row... cursor = arcpy.SearchCursor(File) row = cursor.next() while row: print (row.getValue(field2)) WKT = row.getValue(field1) # this is the part that converts the WKT string to geometry using the defined spatial reference... temp = arcpy.FromWKT(WKT, sr) # append the current geometry to the list... featureList.append(temp) row = cursor.next() # copy all geometries in the list to a feature class... arcpy.CopyFeatures_management(featureList, "C:\\Users\\Team\\Documents\\Theo Laptop Folder\\Tasks\\Quick tasks\\WKTtest\\WKTShapes.shp") # clean up... del row, temp, WKT, File, field1, featureList, cursor
This is in python 2.7 language fyi. (I'd love this in 3.6 if possible...)
Now when I drag the newly created shapefile into Arc it all looks great, but the fields from the CSV aren't carried across...
How can I ammend the code to include all the original string fields from the CSV?
I know a workaround that involves Joining the source csv to the output shapefile, but I'm sure there's a more elegant solution.