I have made a program that reads a file and its main function does some geographic computations to the contents inside. It works now, but instead I want the program to write it instead to a file instead of printing it. I don't understand how to write it because this are so many and i dont know how to convert all of this into one concatenated string then write it into a file.
def main():
with open ("LotData1.txt", "r") as file:
sideList = []
for i in file:
temp = i.strip().split()
sideList.append([temp[0], temp[1], float(temp[2])])
obj = Lot(sideList, "", "")
Departures = obj.getDepartureClosure()
Latitudes = obj.getLatitudeClosure()
Departures_Correction = obj.getDepartureCorrectedClosure()
Latitudes_Correction = obj.getLatitudeCorrectedClosure()
count = len(sideList)
print "INPUT VALUES:\nCOURSE\tBEARING\t\tDISTANCE\t\tLATITUDE\tCORRECTION\tDEPARTURE\tCORRECTION"
for i in range(count):
print "%s \t %s \t %+6.3f\t%+10.3f\t%+10.3f\t%+10.3f\t%+10.3f"%\
(sideList[i][0], sideList[i][1], sideList[i][2], obj.getLatitudeClosure()[i], Latitudes_Correction[i], Departures[i], Departures_Correction[i])
AdjustedLatitudes, AdjustedDepartures, Adjusted_Distances = obj.adjustByCompassRule()
AdjustedBearings = obj.adjustBearings()
print "\n\nADJUSTED VALUES:\nCOURSE\tLATITUDE\tDEPARTURE\tDISTANCE\tBEARING"
for i in range(count):
print "%s\t%+10.3f\t%+10.3f\t%+10.3f\t%5d-%d-%d"%\
(sideList[i][0], AdjustedLatitudes[i], AdjustedDepartures[i], Adjusted_Distances[i],AdjustedBearings[0][i],AdjustedBearings[1][i],AdjustedBearings[2][i])
Northings = obj.GetNorthings()
Eastings = obj.GetEastings()
print "\n\nADJUSTED COORDINATES:\nCORNER\tNORTHING\tEASTING"
for i in range(count):
print "%s\t%10.3f\t%10.3f" %\
(sideList[i][0][0:1],Northings[i-1],Eastings[i-1])
LEC = obj.getLinearErrorOfClosure()
TotalDistance = obj.getTotalDistance()
Departure_Closure = sum(Departures)
Latitude_Closure = sum(Latitudes)
RelativePrecision = obj.getRelativePrecision()
LECBearing = obj.getLECBearingToString()
CorrLatClosure = obj.getLatCorrectedClosure()
CorrDepClosure = obj.getDepCorrectedClosure()
print
print "OTHER STATISTICS:"
print " LATITUDE CLOSURE:", Latitude_Closure
print " DEPARTURE CLOSURE:", Departure_Closure
print
print " LINEAR ERROR OF CLOSURE (LEC):", LEC
print " LEC BEARING: ", LECBearing
print
print " TOTAL DISTANCE:", TotalDistance
print " RELATIVE PRECISION: 1:", RelativePrecision
print " CORRECTED LATITUDE CLOSURE:", CorrLatClosure
print " CORRECTED DEPARTURE CLOSURE", CorrDepClosure