Skip to content

Commit c12b5c4

Browse files
authored
Merge pull request #28 from pierGit7/feat/read_user_input
feat: Read user csv files paths from user input
2 parents a698420 + 441fa98 commit c12b5c4

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

src/analysis.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from common.csvreader import read_csv
2+
import sys
3+
4+
def main():
5+
architecture, budgets, tasks = read_csv()
6+
7+
8+
9+
10+
if __name__ == "__main__":
11+
main()

src/common/csvreader.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pandas as pd
22
import os
3+
import sys
34

45
from common.architecture import Architecture
56
from common.budget import Budget
@@ -69,6 +70,35 @@ def read_tasks(csv:str)-> list[Task]:
6970

7071
return tasks
7172

73+
def read_csv() -> tuple[list[Architecture], list[Budget], list[Task]]:
74+
if len(sys.argv) != 4:
75+
print("Usage: python analysis.py <architecture.csv> <budget.csv> <tasks.csv>")
76+
sys.exit(1)
77+
78+
architecture_file = sys.argv[1]
79+
budget_file = sys.argv[2]
80+
tasks_file = sys.argv[3]
81+
82+
try:
83+
architectures = read_architectures(architecture_file)
84+
budgets = read_budgets(budget_file)
85+
tasks = read_tasks(tasks_file)
86+
87+
print(f"Successfully read architectures: {architectures}")
88+
print(f"Successfully read budgets: {budgets}")
89+
print(f"Successfully read tasks: {tasks}")
90+
91+
# Add your analysis code here
92+
93+
except FileNotFoundError as e:
94+
print(f"Error: File not found - {e}")
95+
sys.exit(1)
96+
except Exception as e:
97+
print(f"Error processing files: {e}")
98+
sys.exit(1)
99+
100+
return architectures, budgets, tasks
101+
72102
def _get_csv_path(csv:str) -> str:
73103
if os.path.exists(csv):
74104
return csv

0 commit comments

Comments
 (0)