AnsweredAssumed Answered

question about coordinates

Question asked by dzestis94 on Apr 28, 2017
Latest reply on Apr 28, 2017 by Dan_Patterson

Hi everyone!

 

I need your help again... So I have this code now, which takes all columns from database I need. The X and the Y coordinates fields isn`t at the database. How do I add two new columns only in exporting CSV file ? 

 

Thanks for any help!  

import arcpy 
import csv

fc = r"#"
out_csv = r"#.csv"

fields = ["#", "#"]

def tableToCSV(fc, out_csv):
    fld_list = arcpy.ListFields(fc)
    fld_names = [fld.name for fld in fld_list]
    with open(out_csv, 'wb') as csv_file:
        writer = csv.writer(csv_file, delimiter=';', lineterminator='\n')
        writer.writerow(fields)
        with arcpy.da.SearchCursor(fc, fields) as cursor:
            for row in cursor:
                writer.writerow(row)
        print out_csv 
    csv_file.close()



tableToCSV(fc, out_csv)

Outcomes