import csv import os import arcpy def main(input_csv, output_shapefile): workspace = r"C:\temp\py_temp" arcpy.env.workspace = workspace shapefile = r"C:\temp\py_temp\import_template.shp" out_path = workspace out_name = output_shapefile geometry = "POINT" template = shapefile arcpy.CreateFeatureclass_management(out_path, out_name, geometry, template) i_curs = arcpy.InsertCursor(out_name) with open(input_csv, "rb") as csvfile: open_reader = csv.reader(csvfile, delimiter=',') for blank, id, Name, DBH, Staff, Longitude, Latitude in open_reader: i_row = i_curs.newRow() i_row.ID = id Name = Name.capitalize() i_row.Name = Name i_row.DBH = DBH i_row.Staff = Staff i_row.Longitude = Longitude i_row.Latitude = Latitude i_curs.insertRow(i_row) del open_reader del i_curs del i_row print "done" if __name__ == '__main__': csv_file = r"C:\temp\py_temp\SB.txt" shp_name = "shapefile2.shp" main(csv_file, shp_name)
name_list = ["Ash", "Dogwood", "Hickory", "Maple", "Oak"] ... Name = Name.capitalize() if Name not in name_list: for name_proper in name_list: if Name.startswith(name_proper[0]): Name = name_proper i_row.Name = Name
import difflib ... Name = difflib.get_close_matches(Name, ["Ash", "Hickory", "Oak", "Dogwood", "Maple"])[0]
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.