I am trying to write a program that calculates a table using arcpy and then converts the table into a specific format for another program to read. The format I am getting is listed at the bottom, enumerated and comma seperated. I would like the format to only have the 2nd 2 fields seperated by a space e.g. 89.99 90.35 My formatting attermpts have thus far been unsuccessful, can anybody point me in the right direction? Many thanks
import arcpy,csv
table = "TABLE_OUTPUT2"
outfile = "TXT-TABLE"
fields = arcpy.ListFields(table)
field_names = [field.name for field in fields]
with open(outfile,'wb') as f:
w = csv.writer(f)
for row in arcpy.SearchCursor(table):
field_vals = [row.getValue(field.name) for field in fields]
print field_vals
w.writerow(field_vals)
del row
[1, 89.99999999446867, 90.3567070001462]
[2, 88.99999999460778, 89.83622323918551]
[3, 87.99999999448423, 89.1722770229037]