reorg parsers
This commit is contained in:
22
utils/csv/loaders.py
Normal file
22
utils/csv/loaders.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from utils.database.loader_action import load_data, update_status, DATA_LOADED
|
||||
from utils.csv.data_preparation import make_pipe_sep_matrix, make_ain_din_matrix, make_channels_matrix
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def main_loader(cfg: object, id: int, action: str) -> None:
|
||||
type_matrix_mapping = {
|
||||
"pipe_separator": make_pipe_sep_matrix,
|
||||
"analogic_digital": make_ain_din_matrix,
|
||||
"channels": make_channels_matrix
|
||||
}
|
||||
if action in type_matrix_mapping:
|
||||
function_to_call = type_matrix_mapping[action]
|
||||
# Create a matrix of values from the data
|
||||
matrice_valori = function_to_call(cfg, id)
|
||||
# Load the data into the database
|
||||
if load_data(cfg, matrice_valori):
|
||||
update_status(cfg, id, DATA_LOADED)
|
||||
else:
|
||||
logger.warning(f"Action '{action}' non riconosciuta.")
|
||||
Reference in New Issue
Block a user