microquantum.analytics.csv_loader

CSV and DataFrame ingestion for analytics modules.

Provides utilities to load data from CSV files or numpy arrays.

Module Contents

microquantum.analytics.csv_loader.load_csv(filepath, delimiter=',', has_header=True)[source]

Load data from a CSV file.

Parameters:
  • filepath (str) – Path to the CSV file.

  • delimiter (str) – Column delimiter.

  • has_header (bool) – If True, first row is treated as header.

Returns:

Tuple of (column_names, data_array).

Return type:

tuple[list[str], numpy.ndarray]

microquantum.analytics.csv_loader.load_csv_column(filepath, column, delimiter=',')[source]

Load a single column from a CSV file.

Parameters:
  • filepath (str) – Path to the CSV file.

  • column (str) – Column name to load.

  • delimiter (str) – Column delimiter.

Returns:

1D numpy array of the column values.

Return type:

numpy.ndarray

microquantum.analytics.csv_loader.load_distance_matrix(filepath, delimiter=',')[source]

Load a distance matrix from a CSV file.

The CSV should have cities as rows and columns, with distances. First row and column can be city names (optional).

Parameters:
  • filepath (str) – Path to the CSV file.

  • delimiter (str) – Column delimiter.

Returns:

2D numpy array of distances.

Return type:

numpy.ndarray

microquantum.analytics.csv_loader.arrays_to_csv(filepath, headers, data, delimiter=',')[source]

Save numpy arrays to a CSV file.

Parameters:
  • filepath (str) – Path to save the CSV file.

  • headers (list[str]) – Column names.

  • data (numpy.ndarray) – 2D numpy array of data.

  • delimiter (str) – Column delimiter.

Return type:

None