sampo.userinput.parser.csv_parser#

Overview#

Classes#

CSVParser

-

Classes#

class sampo.userinput.parser.csv_parser.CSVParser#
static read_graph_info(project_info: str, history_data: str | None = None, full_connections: bool = False, change_base_on_history: bool = False) pandas.DataFrame#

Read the input data about work graph and preprocess it.

Schema of WorkGraph .csv file:
mandatory fields:

activity_id: str - Id of the current task, measurement: str - Measure of the size of the current task (e.g., km, pcs, lit), volume: float - Volume of the current task

optional fields:

granular_name: str - Task name as in the document, predecessor_ids: list[str] - Ids of predecessors of the current task, connection_types: list[str] - Types of links between the current task and its predecessors, lags: float - Time lags, min_req: dict[str: float] - A dictionary containing the minimum amount of each resource that is required to perform the current task max_req: dict[str: float] - A dictionary containing the maximum amount of each resource that is required to perform the current task

Schema of history .csv file (optional data):
mandatory fields:

granular_smr_name: str - Task name as in the document, first_day: str - Date of commencement of the work, last_day: str - Date of completion upper_works: list[str] - Names of predecessors of the current task

ATTENTION!

1) If you send WorkGraph .csv file without data about connections between tasks, you need to provide .csv history file - the SAMPO will be able to reconstruct the connections between tasks based on historical data. 2) If you send WorkGraph .csv file with column ‘predecessor_ids’, ‘lags’ etc. and there is no info in these columns, so framework repair the info from history data

Parameters:
  • project_info – path to the works’ info file

  • history_data – path to the history data of connection file

  • full_connections – does the project information contain full details of the works?

  • change_base_on_history – whether it is necessary to change project information based on connection history data?

Returns:

preprocessed info about works

static work_graph_and_contractors(works_info: pandas.DataFrame, contractor_info: str | list[sampo.schemas.contractor.Contractor] | None = None, contractor_types: list[int] | None = None, unique_work_names_mapper: sampo.utilities.task_name.NameMapper | None = None, work_resource_estimator: sampo.schemas.time_estimator.WorkTimeEstimator = DefaultWorkEstimator(), contractors_number: int = 1)#

Gets a info about WorkGraph and Contractors from file .csv.

Schema of Contractors .csv file (optional data):
mandatory fields:

contractor_id: str - Id of the current contractor, name: str - Contractor name as in the document

optional fields:

{names of resources}: float - each resource is a separate column

ATTENTION!
  1. If you do not provide work resource estimator, framework uses built-in estimator

Parameters:
  • works_info – dataFrame that contains preprocessed info about work graph structure

  • contractor_types

  • contractors_number – if we do not receive contractors, we need to know how many contractors the user wants,

for a generation :param contractor_info: path to contractor info .csv file or list of Contractors :param work_resource_estimator: work estimator that finds necessary resources, based on the history data :return: WorkGraph and list of Contractors