arcpy.AddMessage("Writing records to Owner List...") f1 = open(oName,'w') # Write the record header f1.write("OWNER1|OWNER2|MAIL1|MAIL2|CITY_STATE_ZIP5_ZIP4" + "\n") rows = arcpy.SearchCursor(ParcelLayer) #(NotifyLyr) #(ParcelLayer) cnt = 0 LabelCnt = 0 PageCnt = 1 f1.write(str(DirName+"|Page"+(str(PageCnt))+"| | |") + "\n") f1.write(str(AppName+"|"+AppName2+"|"+AppStreet+"|"+AppCityZip) + "\n") for row in rows: cnt = cnt + 1 LabelCnt = LabelCnt + 1 f1.write(str(row.getValue("OwnerName")) + "|" + str(row.getValue("SecondName")) + "|" + str(row.getValue("MailHouseNo"))+ " " + str(row.getValue("MailAddressLine1")) + "|" + str(row.getValue("MailAddressLine2")) + "|" + str(row.getValue("MailCity"))+ " " + str(row.getValue("MailState")) + " " + str(row.getValue("MailZip5")) + " " + str(row.getValue("MailZip4")).replace("|None|","| |") + "\n") if LabelCnt == 29: PageCnt = PageCnt + 1 f1.write(str(DirName+"|Page"+(str(PageCnt))+"| | |") + "\n") LabelCnt = 0 f1.close() del row, rows # Some records reflect a null vale as |None|, replace these with a blank FoName = wPath+DirName+"\\"+DirName+"-o.txt" f1 = open(oName,'r') f2 = open(FoName, 'w') lines = f1.readlines() for line in lines: f2.write(line.replace("None"," ")) f1.close f2.close arcpy.Delete_management(oName)
Solved! Go to Solution.
What I am doing wrong?
>>> f1.close # just prints the string rep of the object <built-in method close of file object at 0x01E55E90> >>> f1.close() # with the parens the function will actually do the close
What I am doing wrong?
>>> f1.close # just prints the string rep of the object <built-in method close of file object at 0x01E55E90> >>> f1.close() # with the parens the function will actually do the close