I am learning python for the first time and I've just learned that readlines() is incredibly slow and taxing on memory. This would be fine, but as I am programming for a data structures class with up to 10^6 inputs, I believe that runtime is very important.
This is what I have so far that works. I did not strip the '\r' yet.
def generateListOfPoints(stuff):
List = open(stuff).readlines()
a = []
for i in range(len(List)):
a.append(List[i].rstrip('\n').split(","))
return a
This is what I tried to do with a for loop (which I heard was better), but all I'm getting is errors and I don't know what is going on.
def generateListOfPoints(stuff):
a = []
with open(stuff) as f:
for line in f:
a.append(stuff.rstrip('\n').rstrip('\r').split(","))
return a