4 followers Follow

Write report to file in python


I'm trying to convert a script from easi to python, but require that a report be written to a file, so that I can parse it for key info later in the workflow. In easi the function has a REPORT parameter which can be set to a file. That parameter is not available in python, so till now I have only been able to print the report information on the terminal. How can I save this information to a text file?

Any help would be appreciated!

Christiaan Lott Answered

Please sign in to leave a comment.



Hello Christiaan,

Thank you for the question and using our forum.

It is a little different in Python, we have a class called Report, in the pci.nspio module that is now responsible for handling all reporting operations of all of our PCI functions (PPFs).

For example, to write the report for the APMODEL function, which prints out all of the accuracy statistics for your GCPs and Tie Points after performing the airphoto block bundle adjustment, you can do the following:

from pci.apmodel import apmodel
from pci.nspio import Report, enableDefaultReport
from pci.exceptions import PCIException

rep_file = r'c:\test\rep.txt' # points to the report file you want to write the report info to


    # You can run other PCI functions before closing the report file, which will append to the end of the file

except PCIException, e:
    print e

    enableDefaultReport('term') # this will close the report file
Shawn Melamed 2 votes
Comment actions Permalink