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?
-
There is not enough information to go on here. What does the rest of your model look like? A screenshot would be helpful. Also note the last two paragraphs of my answer, about the "quirk" with iterators (try nesting the iterated part in a sub-model).blah238– blah2382012年06月07日 03:05:57 +00:00Commented Jun 7, 2012 at 3:05
-
@whuber this is a Calculate Value tool, not Calculate Field, so there is no implicit iteration within it.blah238– blah2382012年06月07日 03:07:09 +00:00Commented Jun 7, 2012 at 3:07
-
1@Abehrer, please note I have updated my answer to the linked question.blah238– blah2382012年06月07日 06:45:15 +00:00Commented Jun 7, 2012 at 6:45
-
Thanks, @blah238. I will delete that comment to avoid misleading people.whuber– whuber2012年06月07日 15:36:55 +00:00Commented Jun 7, 2012 at 15:36