How to overwrite printed text; Python 2.7.18.4

32 Views Asked by At

I have the following code in Python 2.7.18.4 and when I run it, for each Tax Parcel Map, it prints the date and time and which parcel it is currently working on. When it is done and continues to the next parcel, it drops down a line on screen and prints the next parcel number it is working on.

import arcpy
import time

import_path = r"D:\DDP_ArcMap\Parcels_Data-Driven-Pages_blank.mxd"   # Path of .mxd
export_path = r"D:\DDP_ArcMap\PNG_Parcels\\"   # Path of output file

mxd = arcpy.mapping.MapDocument(import_path)
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
  pageName = str(mxd.dataDrivenPages.pageRow.lrsn)
  pageName = pageName.replace(".0", "")
  arcpy.mapping.ExportToPNG(mxd, export_path + pageName + ".png")
  print time.ctime() +" -- " + "Exporting Tax Parcel Map " + str(pageNum) + " of " + str(mxd.dataDrivenPages.pageCount)
del mxd

Is there a way to overwrite the line each time with which parcel it is currently on along with the current date/time. I've tried several ways such as those listed here but with no luck: How to overwrite the previous print to stdout?

0

There are 0 best solutions below