I am very new to Python programming and have been tasked with writing a program to export a csv file from a file geodatabase feature class. The csv should contain only certain fields and the records exported should be based on last edit date. In other words the csv file will be created on a daily bases containing only the last features added based on "last edit date field".
I have this so far:
import arcpy
import os
import csv
import domainvalues
def export_to_csv(dataset, output, dialect):
"""Output the data to a CSV file"""
# create the output writer
out_writer = csv.writer(open(output, 'wb'), dialect=dialect)
# return the list of field names and field values
header, rows = domainvalues.header_and_iterator(dataset)
# write the field names and values to the csv file
out_writer.writerow(map(domainvalues._encodeHeader, header))
for row in rows:
out_writer.writerow(map(domainvalues._encode, row))
if __name__ == "__main__":
# Get parameters
dataset_name = arcpy.GetParameterAsText(0)
output_file = arcpy.GetParameterAsText(1)
delim = arcpy.GetParameterAsText(2).lower()
dialect = 'excel'
if delim == 'comma':
pass
else:
dialect = 'excel-tab'
try:
export_to_csv(dataset_name, output_file, dialect)
except Exception as err:
arcpy.AddError('Error: {0}'.format(err))
However its exporting everything.