reorg parsers
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!.venv/bin/python
|
||||
from utils.database.connection import connetti_db
|
||||
from utils.database.nodes_query import get_nodes_type
|
||||
import utils.timestamp.date_check as date_check
|
||||
import logging
|
||||
import re
|
||||
@@ -32,7 +33,7 @@ def get_data(cfg: object, id: int) -> tuple:
|
||||
conn.close()
|
||||
return unit_name, tool_name, tool_data
|
||||
|
||||
def make_matrix(cfg: object, id: int) -> list:
|
||||
def make_pipe_sep_matrix(cfg: object, id: int) -> list:
|
||||
"""
|
||||
Processes raw tool data and transforms it into a matrix format for database insertion.
|
||||
|
||||
@@ -67,7 +68,7 @@ def make_matrix(cfg: object, id: int) -> list:
|
||||
|
||||
return matrice_valori
|
||||
|
||||
def make_loc_matrix(cfg: object, id: int) -> list:
|
||||
def make_ain_din_matrix(cfg: object, id: int) -> list:
|
||||
"""
|
||||
Processes raw location (LOC) tool data and transforms it into a matrix format for database insertion.
|
||||
|
||||
@@ -101,7 +102,7 @@ def make_loc_matrix(cfg: object, id: int) -> list:
|
||||
|
||||
return matrice_valori
|
||||
|
||||
def make_matrix_with_channels(cfg: object, id: int, node_channels: list) -> list:
|
||||
def make_channels_matrix(cfg: object, id: int) -> list:
|
||||
UnitName, ToolNameID, ToolData = get_data(cfg, id)
|
||||
righe = ToolData.splitlines()
|
||||
matrice_valori = []
|
||||
@@ -110,11 +111,11 @@ def make_matrix_with_channels(cfg: object, id: int, node_channels: list) -> list
|
||||
EventDate, EventTime = timestamp.split(' ')
|
||||
valori_splitted = [valore for valore in rilevazioni.split(';') if valore != '|']
|
||||
valori_iter = iter(valori_splitted)
|
||||
node_channels, node_types, node_ains, node_dins = get_nodes_type(cfg, ToolNameID, UnitName)
|
||||
|
||||
valori_nodi = [list(islice(valori_iter, channels)) for channels in node_channels]
|
||||
|
||||
for num_nodo, valori in enumerate(valori_nodi, start=1):
|
||||
matrice_valori.append([UnitName, ToolNameID, num_nodo, date_check.conforma_data(EventDate), EventTime, batlevel, temperature] + valori + ([None] * (19 - len(valori))))
|
||||
|
||||
return matrice_valori
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user