-
Notifications
You must be signed in to change notification settings - Fork 1
/
read_files.py
44 lines (37 loc) · 1.46 KB
/
read_files.py
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
38
39
40
41
42
43
44
from power_plant import PowerPlant
from period_plant import PeriodPlant
# Global Variables:
number_of_units = 0
number_of_periods = 0
unit = []
period = []
def read_file_1():
file = open("Input_files/File1.txt", "r")
global number_of_units, unit
number_of_units = int(file.readline())
print("Number of units :", number_of_units)
for index in range(int(number_of_units)):
unit_id = file.readline()
unit_capacity = file.readline()
unit_maintenance_period = file.readline()
unit.append(PowerPlant(unit_id, unit_capacity, unit_maintenance_period))
print("------------------------")
print("Unit ID :", unit_id, end="")
print("Unit capacity :", unit_capacity, end="")
print("Maintenance Period :", unit_maintenance_period, end="")
file.close()
print("\n\n=-=-=-=-=-=-=-=-=-=-=-=-\n")
def read_file_2():
file = open("Input_files/File2.txt", "r")
global number_of_periods, period
number_of_periods = int(file.readline())
print("Number of periods :", number_of_periods)
for index in range(int(number_of_periods)):
period_id = file.readline()
period_requirement = file.readline()
period.append(PeriodPlant(period_id, period_requirement))
print("---------------------------")
print("Period ID :", period_id, end="")
print("Period Requirement :", period_requirement, end="")
file.close()
print("\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=\n")