BibsTransformer#
Transform MARC bibliographic records into FOLIO Instance records and prepare MARC data for loading to SRS via Data Import.
When to Use This Task#
Migrating bibliographic data from a legacy ILS with MARC21 records
Creating FOLIO Instances with corresponding SRS (Source Record Storage) records
Supporting various ILS flavors: Voyager, Sierra, Aleph, Koha, and others
Configuration#
Configuration keys can be provided in either camelCase or snake_case in JSON files.
The examples below use camelCase for consistency.
{
"name": "transform_bibs",
"migrationTaskType": "BibsTransformer",
"ilsFlavour": "tag001",
"hridHandling": "preserve001",
"updateHridSettings": false,
"tagsToDelete": ["841", "852"],
"statisticalCodesMapFileName": "statistical_codes.tsv",
"statisticalCodeMappingFields": ["998$a$b"],
"files": [
{
"file_name": "bibs.mrc",
"discovery_suppressed": false
},
{
"file_name": "bibs_suppressed.mrc",
"discovery_suppressed": true
}
]
}
Parameters#
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
The name of this task. Used to identify the task and name output files. |
|
string |
Yes |
Must be |
|
string |
Yes |
The ILS type for legacy ID handling. See ILS Flavours below. |
|
string |
No |
MARC field containing legacy ID when ILS flavour is |
|
boolean |
No |
Add administrative notes containing legacy IDs. Default: |
|
string |
No |
How to handle HRIDs. |
|
boolean |
No |
Disable adding MARC 035 from legacy 001/003 during HRID handling. Default: |
|
boolean |
No |
Generate MARC output for Data Import overlay workflow. Default: |
|
boolean |
No |
Parse mapped |
|
boolean |
No |
Reset instance HRID counter before processing. Default: |
|
boolean |
No |
Whether to update FOLIO HRID settings after transformation. Default: |
|
array |
No |
MARC tags to remove before saving to output MARC file. |
|
string |
No |
TSV file mapping legacy codes to FOLIO statistical codes. |
|
array |
No |
MARC fields to extract statistical codes from (e.g., |
|
boolean |
No |
Task-level control for creating SRS records. Default: |
|
array |
Yes |
List of MARC files to process. See File Configuration. |
Note
Task-level createSourceRecords and per-file create_source_records are both applied.
SRS records are only created when both are true, and dataImportMarc is false.
Note
When dataImportMarc is true, BibsTransformer forces 035 generation from 001/003 off in the HRID flow.
MARC Record Preprocessors#
BibsTransformer can apply MARC preprocessors to each pymarc.Record before mapping it to FOLIO.
marcRecordPreprocessors: ordered list of preprocessor names or full module paths.preprocessorsArgs: inline JSON object or the name of a JSON file inmapping_files/containing per-preprocessor arguments.
By default, the task includes folio_migration_tools.marc_rules_transformation.marc_reader_wrapper.set_leader, which normalizes leader bytes 09-11 and 20-23. If you provide your own marcRecordPreprocessors list and omit that preprocessor, it will not run.
All preprocessors are called with the task’s migration_report object via keyword arguments. Custom preprocessors must accept **kwargs.
Example:
{
"name": "transform_bibs",
"migrationTaskType": "BibsTransformer",
"ilsFlavour": "voyager",
"marcRecordPreprocessors": [
"folio_migration_tools.marc_rules_transformation.marc_reader_wrapper.set_leader",
"folio_data_import.marc_preprocessors.clean_empty_fields"
],
"preprocessorsArgs": {
"default": {
"log_level": "DEBUG"
}
},
"files": [
{
"file_name": "bibs.mrc"
}
]
}
ILS Flavours#
The ilsFlavour parameter determines how the legacy system identifier is extracted from MARC records:
Value |
Legacy ID Source |
|---|---|
|
001 (with processing) |
|
001 |
|
907$y |
|
907$y |
|
999$c |
|
907$y |
|
001 |
|
990$a |
|
Field specified in |
|
UUID generated |
File Configuration#
Each file object in the files array supports:
Property |
Type |
Description |
|---|---|---|
|
string |
Name of the MARC file in |
|
boolean |
Mark all records from this file as discovery suppressed |
|
boolean |
Mark all records from this file as staff suppressed |
|
string |
Statistical code(s) to assign to all records. Use |
|
boolean |
Include records in the output MARC file for Data Import. Default: |
|
boolean |
Create SRS records for these bibs. Default: |
Source Data Requirements#
Location: Place MARC21 binary files (
.mrc) initerations/<iteration>/source_data/instances/Format: Standard MARC21 binary format
Encoding: UTF-8 recommended
Decoding Error Handling#
BibsTransformer uses permissive MARC decoding with per-record diagnostics and recovery
heuristics.
See MARC Decoding and Recovery Behavior for full details of the shared decoding pipeline and heuristic order.
MARC-8 decoding warnings are logged but do not stop processing.
Some decode failures are automatically repaired (for example, MARC-8 leader and MARCMaker dagger marker issues).
Records that cannot be repaired are skipped and logged as failed.
Use the following outputs to review decoding behavior:
reports/data_issues_log_<task_name>.tsvfor warning and repair messages.reports/report_<task_name>.mdfor repaired vs failed decode counts.results/failed_records_decode_<task_name>.mrcfor records that fail MARC decoding.results/failed_records_transformation_<task_name>.mrcfor records that fail transformation (e.g., missing required fields).
Output Files#
Files are created in iterations/<iteration>/results/:
File |
Description |
|---|---|
|
FOLIO Instance records (one per line) |
|
MARC21 file for loading via Data Import |
|
Legacy ID to FOLIO UUID mapping |
|
MARC records that failed to decode from MARC21 format |
|
MARC records that decoded OK but failed transformation (empty only if no failures) |
Reports are created in iterations/<iteration>/reports/:
File |
Description |
|---|---|
|
Transformation statistics and mapping report |
|
Data issues requiring attention |
Examples#
Basic Example#
Transform MARC bibs with default HRID generation:
{
"name": "transform_bibs",
"migrationTaskType": "BibsTransformer",
"ilsFlavour": "voyager",
"files": [
{
"file_name": "bibs.mrc"
}
]
}
Preserving 001 as HRID#
{
"name": "transform_bibs",
"migrationTaskType": "BibsTransformer",
"ilsFlavour": "tag001",
"hridHandling": "preserve001",
"files": [
{
"file_name": "bibs.mrc"
}
]
}
Multiple Files with Different Settings#
{
"name": "transform_bibs",
"migrationTaskType": "BibsTransformer",
"ilsFlavour": "sierra",
"tagsToDelete": ["9XX"],
"files": [
{
"file_name": "regular_bibs.mrc",
"discovery_suppressed": false
},
{
"file_name": "suppressed_bibs.mrc",
"discovery_suppressed": true
},
{
"file_name": "equipment.mrc",
"discovery_suppressed": false,
"data_import_marc": false
}
]
}
With Statistical Code Mapping#
{
"name": "transform_bibs",
"migrationTaskType": "BibsTransformer",
"ilsFlavour": "tag001",
"statisticalCodesMapFileName": "stat_codes.tsv",
"statisticalCodeMappingFields": ["998$a", "998$b"],
"files": [
{
"file_name": "bibs.mrc",
"statistical_code": "migrated"
}
]
}
Running the Task#
folio-migration-tools mapping_files/config.json transform_bibs --base_folder ./
Next Steps#
After running BibsTransformer:
Post Instances: Use InventoryBatchPoster or BatchPoster to load Instance records
Load MARC to SRS: Use MARCImportTask to import the MARC file via Data Import
Transform Holdings: Use HoldingsMarcTransformer or HoldingsCsvTransformer
See Also#
MARC Rules Based Mapping - Customizing MARC-to-Instance mapping
Statistical Code Mapping - Mapping statistical codes from MARC
InventoryBatchPoster - Posting transformed instances
MARCImportTask - Loading MARC records to SRS