One oddity - the first time I run it, I don't get results. I click run a second time (using IDLE) and it works. Any idea why?
Looks like the file buffer didn't get written to disk.Did you close the file?outputTxtFile.close()
If that didn't work you may want to try this:outputTxtFile.flush()
outputTxtFile.close()
You don't need an external script, you could do this with the Calculate Value tool. Set up the input features as a precondition.Expression:writeFile(r"%Input Features%","FTEXT",r"c:\outfolder\outFile.txt")
Code Block:
import arcpy
def writeFile(inTable,Field,outFile):
f = open(outFile, 'w')
rows = arcpy.SearchCursor(inTable)
for row in rows:
f.write(str(row.getValue(Field)) + "\n")
f.close()
Output type: File