I am working on a problem and trying to read a data and creating a chart the problem is when ever I read any thing from file it add \n or \r in with it but I change the type of digital data but I dont know what to do with string data like names. so far I am stuck here is my code.
class Student:
def __init__(self,Fname,Lname,Tid,CrdtEarn,QualityPnts):
self.Fname=Fname
self.Lname=Lname
self.Tid=Tid
self.CrdtEarn=CrdtEarn
self.QualityPnts=QualityPnts
## def __str__(self):
## return self.Fname+self.Lname+" is the student with Tech ID "+str(self.Tid)+" earned "+\
## str(self.CrdtEarn)+" and have "+str(self.QualityPnts)+" points."
def getFname(self):
return self.Fname
def getLname(self):
return self.Lname
def getTid(self):
return self.Tid
def getCrdtEarn(self):
return self.CrdtEarn
def getQualityPnts(self):
return self.QualityPnts
def Update(self,addHours,addQpoints):
self.CrdtEarn=CrdtEarn+addHours
self.QualityPnts=QualityPnts+addQpoints
ListF=[]
ListL=[]
ListT=[]
ListC=[]
ListQ=[]
def read():
inFile=open("prog3.txt","r")
flag=False
count=0
while not flag:
fName=inFile.readline()
if (fName != ""):
count+=1
lName=inFile.readline()
tid=inFile.readline()
crdt=inFile.readline()
points=inFile.readline()
tid=int(tid)
crdt=int(crdt)
points=int(points)
s=Student(fName,lName,tid,crdt,points)
## print List
ListF.append(s.Fname)
ListL.append(s.Lname)
ListT.append(s.Tid)
ListC.append(s.CrdtEarn)
ListQ.append(s.QualityPnts)
## print s
else:
flag=True
## print count
inFile.close()
return ListF,ListF,ListL,ListT,ListC,ListQ
def main():
read()
print ListF[0],ListL[0]
print ListL,"\n"
print ListT,"\n"
print ListC,"\n"
print ListQ,"\n"
main()
If anyone can help me I would be grateful
and this code is still incomplete