2

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?

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

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.