Importers#
An importer reads an external file format and turns it into SAMSON data.
Use an importer when the main job of your extension is to parse files and create or update nodes in the data graph. Typical examples include molecular structure formats, volumetric maps, custom simulation outputs, and project exchange formats.
Importers are available when users open files from Home > File, and they can also be invoked programmatically.
Key class and core responsibilities#
File importers derive from SBIFileImporter.
An importer is expected to:
- advertise the handled file extension through
SBIFileImporter::getExtension - provide a user-facing file dialog filter through
SBIFileImporter::getFilter - implement
importFromFileto parse the input and populate or update the data graph
How importers are used#
An importer may run in two common situations:
- a user opens a file in the SAMSON UI
- a developer calls
SAMSON::importFromFile(...)and lets SAMSON dispatch to the appropriate importer
That means an importer should be robust both in interactive use and in automation workflows.
What a good importer does in practice#
A well-behaved importer usually does more than parse text or binary records. It also:
- creates the right node hierarchy in the data graph
- preserves as much semantic information as the format allows
- reports errors clearly when the file is malformed or incomplete
- behaves predictably when optional data is missing
If your format carries scientific metadata, decide early which parts become persistent node state, which parts become properties, and which parts are ignored.
Example scenario#
Suppose you are adding support for a custom trajectory snapshot format:
- the importer reads the file header and per-frame records
- it creates or updates structural nodes in the data graph
- it stores any import-specific metadata needed later for analysis or visualization
If that format also needs a custom visual representation, the importer may create nodes that are later rendered by a visual model.
What to read next#
- Use Extension Generator to scaffold an importer.
- Read Exporters if you also need the reverse workflow.
- Read Serialization if imported data must later be saved in SAMSON documents.