Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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"]
 rows = zip(*map(lambda x: x.split(';'), [featureclassnames, nnzscorevalue, nnexpectedvalue, nnobservedvalue, pvaluescore, nnratiovalue]))

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?

share|improve this question
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 Jun 7 '12 at 3:05
@whuber this is a Calculate Value tool, not Calculate Field, so there is no implicit iteration within it. –  blah238 Jun 7 '12 at 3:07
@Abehrer, please note I have updated my answer to the linked question. –  blah238 Jun 7 '12 at 6:45
Thanks, @blah238. I will delete that comment to avoid misleading people. –  whuber Jun 7 '12 at 15:36
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.