1

I have a model where the user inserts different model parameters like "Name", "Elevation", "Threshold A", "Threshold B" and so on. Based on this, features get selected, saved to .xls files where they feed a chart/diagram maker for a report. To these charts, I need to include (or link) the model parameters the user inserted. I would like to write them to an Excel file, but any table is fine.

Example

I thought of writing those variables to a newly created GeoDatabase table with the Calculate Field Tool (the table already had its field names and data types according to the variables), but I'm not good in Python. It also said that the table had no records. I tried with another table with existing records by calculating the fields I had added, but without success.

Is there any (easy) way to export my variables to a list or table I can then export to Excel format?

1 Answer 1

1

I would resolve this by calling a small python script to write out to say a CSV file.

The following example is for ArcMap 10.6

The test model is as:

Test model

Note the parameters are preconditions to the tool, they need to exist before the tool executes

The Calculate Value tool is as:

Calculate Value Tool

Here is the code:

Expression:

SaveParameters("%Name%","%Elevation%","\n")

Note the inline substitutions are within quotes to pass them in as text and eol character needs to be passed in as ESRI have introduced a bug into the tool, which I have brought to their attention but seem unable to fix it.

Code Block:

def SaveParameters(name,ele,eol):
  myfile = open(r"c:\temp\params.csv","w")
  myfile.write("Name,Elevation" + eol)
  myfile.write(name + "," + ele)
  myfile.close()
  return True
2
  • It took me a little to understand the syntax, but this worked out very well in the end, thanks! Now I can submit my thesis in time ;) Commented Apr 10, 2020 at 1:13
  • Moe you should tick my answer if you found it correct as it allows others seeking similar answers that your question was solved.
    – Hornbydd
    Commented Apr 10, 2020 at 8:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.