import numpy as np
from pathlib import Path
import logging

logger = logging.getLogger(__name__)


def load_data(file: Path) -> tuple[np.ndarray, list]:
    try:
        data = np.loadtxt(file)
        columns =  []
    except ValueError:
        data = np.loadtxt(file, skiprows=1)
        header = file.read_text().splitlines()[0]
        columns = header.split()
    logger.info(f"Loaded {data.shape[0]} rows and {data.shape[1]} columns from {file}")
    return data, columns

