Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calc(file):
- arr = file.readlines()
- arr_2 = []
- for i in arr:
- s = ""
- for j in range(len(i)):
- tmp = i[j]
- if (tmp >= '0' and tmp <= '9') or tmp == '.':
- s = s + tmp
- elif s != "":
- arr_2.append(float(s))
- s = ""
- if s != "":
- arr_2.append(float(s))
- return arr_2
- inputFile = 0
- try:
- inputFile = open('TF14_1.txt', 'w')
- except IOError:
- print("File TF14_1.txt could not be opened")
- else:
- print("Opening file TF14_1.txt for writing.")
- inputFile.write('12354.13542' + '\n' + '78954.1235 1243.43' + '\n' + ' linelineline 3' + '452')
- inputFile.close()
- try:
- inputFile = open('TF14_1.txt', 'r')
- except IOError:
- print("File TF14_1.txt could not be opened")
- else:
- print("Opening file TF14_1.txt for reading.")
- arr = calc(inputFile)
- inputFile.close()
- outputFile = 0
- try:
- outputFile = open('TF14_2.txt', 'w')
- except IOError:
- print("File TF14_1.txt could not be opened")
- else:
- print("Opening file TF14_2.txt for writing.")
- for i in arr:
- outputFile.write(f"{i} ")
- outputFile.write("\n")
- outputFile.close()
- try:
- outputFile = open('TF14_2.txt', 'r')
- except IOError:
- print("File TF14_1.txt could not be opened")
- else:
- print("Opening file TF14_2.txt for reading.")
- arr_2 = calc(outputFile)
- max = arr_2[0]
- for i in arr_2:
- if max < i:
- max = i
- outputFile.close()
- print(arr_2)
- print(f"maximum: {max}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement