Taking text from a file and formatting it
up vote
0
down vote
favorite
My code takes numbers from a large text file, then splits it to organise the spacing and to place it into a 2-dimensional array. The code is used to get data for a job scheduler that I'm building. #reading in workload data def getworkload(): work = strings = with open("workload.txt") as f: read_data = f.read() jobs = read_data.split("n") for j in jobs: strings.append(" ".join(j.split())) for i in strings: work.append([float(s) for s in i.split(" ")]) return work print(getworkload()) The text file is over 2000 lines long, and looks like this: 1 0 1835117 330855 640 5886 945 -1 -1 -1 5 2 1 4 9 -1 -1 -1 2 0 2265800 251924 640 3124 945 -1 ...