Post

4 followers Follow
2
Avatar

Write report to file in python

Hi,

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.

3 comments

2
Avatar

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

try:
    Report.clear()
    enableDefaultReport(rep_file)

    apmodel(oeproj=r'c:\test\activeproject.prj')
    # 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

finally:
    enableDefaultReport('term') # this will close the report file
Shawn Melamed 2 votes
0
Avatar

Thanks for your help! I'm away from the office this week, but I'll give this a try when I get back to the office!.

Christiaan Lott 0 votes