I have a question regarding an answer to "Exporting data from 'collect values' output in ArcGIS model builder". I'm trying to do the same thing as the author to that question and I've followed the steps and the code in that answer. The code I am using is below:
multivaluesToCsv(r"%CSV File%", "%Feature Class Name%", "%NNZScore Value%", "%NNExpected%", "%NNObserved%", "%PValue%", "%NNRatio%") import csv def multivaluesToCsv(csvfile, featureclassnames, nnzscorevalue, nnexpectedvalue, nnobservedvalue, pvaluescore, nnratiovalue): with open(csvfile, 'wb') as f: w = csv.writer(f) columnNames = ["FC", "NNZ", "NNE", "NNO", "PV", "NNR"] w.writerow(columnNames) rows = zip(*map(lambda x: x.split(';'), [featureclassnames, nnzscorevalue, nnexpectedvalue, nnobservedvalue, pvaluescore, nnratiovalue])) w.writerows(rows)
My problem is that the CSV file is only being populated with the final row of values. The titles all appear but only the last iteration's data is included. Any suggestions?