Skip to content

Generic Excel/CSV import via cell-coordinate to property-path mapping #87

@simontaurus

Description

@simontaurus

Feature request

Support importing structured data from Excel/CSV files using a mapping that associates cell coordinates (or column positions) to model property paths.

Concept

A two-phase generic approach:

  1. mapping_to_json(worksheet, mapping): Read cell values from an Excel/CSV file using a mapping dict like {"formula": "D2", "measurements.0.area": "T2"} and assemble a nested JSON dict from the dotted property paths. This phase is fully model-agnostic.

  2. json_to_model(data, ModelClass, context): Construct a typed model instance from the JSON dict, with automatic type coercion driven by the model's field annotations (e.g. int->str where the model expects str). Supports context injection via wildcard paths like measurements.*.sample_info.

Mapping generation

The mapping can be:

  • Auto-generated by analyzing the Excel structure (header row parsing, row grouping via outline_level metadata)
  • Exported to / imported from a JSON file for manual inspection and override
  • Manually defined for custom layouts

Use case

Parsing Compound Discoverer Excel exports (275 columns, nested features with candidates and per-sample measurements spread across distant column ranges). The cell mapping makes the import traceable and debuggable.

Reference implementation

Working prototype in oold-example-env:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions