-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_cost.py
More file actions
37 lines (26 loc) · 892 Bytes
/
Copy pathget_cost.py
File metadata and controls
37 lines (26 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def get_1():
input_file = 'input.txt'
output_file = 'output.txt'
with open(input_file, 'r') as file:
data = file.read()
lines = data.split('\n')
results = []
for line in lines:
if "f= " in line and 'D+05' in line:
start_index = line.index('f=') + 3
end_index = line.index('D+05', start_index)
result = line[start_index:end_index]
results.append(result)
with open(output_file, 'w') as file:
file.write('\n'.join(results))
def get_2():
file_path = "input.txt" # Replace with the actual file path
# Read the file
with open(file_path, 'r') as file:
content = file.read()
# Split the values by commas
values = content.split(", ")
# Write each value on a separate line
with open(file_path, 'w') as file:
file.write('\n'.join(values))
get_2()